可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
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>