Dojo: Get ID of inlineEditBox on OnChange

这一生的挚爱 提交于 2019-12-08 06:41:06

问题


I'm using dojo and dijit and have an inlineEditBox widget. I'm trying to capture the onchange event and send a key/value post to a php page (to set into a database). The value is the new value just submitted, available from e.target.value. That's easy.

I'd like the key value to be the id of the inlineEditBox widget. How can I access that programatically?


回答1:


Since InlineEditBox is a widget it's best not to monitor DOM level events. Instead, why not connect to InlineEditBox.onChange? For example:

<span dojoType="dijit.InlineEditBox" ...>
     <script type="dojo/connect" event="onChange" args="value">
          console.log(this.id + " changed to value" + value);
     </script>
</span>



回答2:


<span data-dojo-type="dijit.InlineEditBox" data-dojo-props="onChange:function(){ applyChange(arguments[0]);}" width="70px" title="Admin Notes">Database Value</span>
<script>
function applyChange(newValue){
    console.log(newValue);
}
</script>


来源:https://stackoverflow.com/questions/816825/dojo-get-id-of-inlineeditbox-on-onchange

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