简体   繁体   中英

submit button does nothing

I have the following code:

<button  data-dojo-type="dijit.form.Button" data-dojo-props='baseClass:"styleButton"'
   name="_action_update"
   type="submit"
   label="Save"
>Save</button>

The problem is, that this doesnt seem to actually work as a submit action anymore. If I take away the dojo related stuff, it works as expected. I have used this baseClass method before to apply a style to a button, but not a submit button. How should I change this?

I think you need an input type="submit"

<input data-dojo-type="dijit.form.Button" data-dojo-props='baseClass:"styleButton"'
  name="_action_update" type="submit" value="Save" />

Or if you really need a button tag, something ugly like this should work

<button onclick="document.getElementById('yourFormId').submit()" data-dojo-type="dijit.form.Button" data-dojo-props='baseClass:"styleButton"'
   name="_action_update" label="Save">Save</button>

Or of course you could more elegantly attach the event handler without the dom level-0 cruft

<button id="formSubmitBtn" data-dojo-type="dijit.form.Button" data-dojo-props='baseClass:"styleButton"'
   name="_action_update" label="Save">Save</button>

document.getElementById("formSubmitBtn").onclick = function() {
    document.getElementById('yourFormId').submit();
};

You have not precised what version of Dojo you are using, but, and I believe that is the problem :

Dojo version < 1.7 do not support data-dojo-props + natural html properties

<input data-dojo-type="dijit.form.Button" data-dojo-props='baseClass:"styleButton"'
  name="_action_update" type="submit" value="Save" />

Will not work, name, type and value will be ignored.

If your dojo version is 1.7 or 1.7.1, then the problem is elsewhere.

Try adding a data-dojo-type="dijit.form.Form to you form tag as such

<div dojoType="dijit.form.Form" id="myFormThree" jsId="myFormThree" encType="multipart/form-data" action="" method="">

referrenced from: http://dojotoolkit.org/reference-guide/dijit/form/Form.html

here is the docs for dijit.form.Button, not sure how helpful they will be.

http://dojotoolkit.org/reference-guide/dijit/form/Button.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM