Value of dojox.CheckedMultiSelect not being posted with dojo.xhrPost

落花浮王杯 提交于 2020-02-02 11:50:06

问题


When I post a form using dojo.xhrPost, I get all the fields in my form POSTed except for the value of my dojox.CheckedMultiSelect, no matter what options are selected.

The declaration of my CheckedMultiSelect:

<div dojoType="dojo.data.ItemFileReadStore" jsId="processTypeList" url="json/processtypelist.json.php"></div>
<label for="processTypeSelect">Process Types</label>
<select dojoType="dojox.form.CheckedMultiSelect" name="processTypeSelect" id="processTypeSelect" multiple="true" style="height:166px;" store="processTypeList"></select>

And here is my xhrPost:

<button dojoType="dojox.form.BusyButton" id="logSearchSubmit" busyLabel="Searching..." timeout="5" 
  onclick="dojo.xhrPost({
    url: 'handlers/logsearch.php',
    form: dojo.byId('formSearch'),
    handleAs: 'json'
});">Search</button>

And here is what I get POSTed:

endDate 2009-12-15
postAction  search
processSelect   
searchAttribute none
searchAttributeValue    
startDate   2009-12-15

Any reason why the dojox control value doesn't get posted, though all the values of the dijit controls that are part of my form get posted? The control is right in between the other ones who's values get POSTed, so I know it is within the form.

I just added another button to perform console.log(formSearch.getValues()) instead of the xhrPost and I get the value of the control logged into the console. So obviously dojo is aware of it, but when I do a console.log(dojo.formToJson("formSearch")) I get all the form data except for the the dojox control again.


回答1:


I'm guessing it's a bug in CheckedMultiSelect that it doesn't carry over the 'name' attribute from the declared markup to the hidden select widget that would be used in a form submit. The dijit.form widgets have to do this in a fairly kludgy way due to some IE behavior, inserting ${nameAttrSetting} directly into the template (CheckedMultiSelect.html) at the select element. See dijit/form/templates/Button.html for an example.

CheckedMultiSelect inherits from dijit, but needs to replicate this fix in its own template, since it cannot be inherited. If this is the solution, please consider submitting a report and patch to bugs.dojotoolkit.org.



来源:https://stackoverflow.com/questions/1908121/value-of-dojox-checkedmultiselect-not-being-posted-with-dojo-xhrpost

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!