Dojo: dojo onblur events

我怕爱的太早我们不能终老 提交于 2019-12-05 10:05:41
GreenWebDev

To add the onBlur event you should use dojo.connect():

dojo.connect(dojo.byId("vehicle_1"), "onBlur", function() { /* do something */ });

If you have multiple inputs that you need to connect this to, consider adding a custom class for those that need to blur and using dojo.query to connect to all of them:

Vehicle:
    <input dojoType="dijit.form.ComboBox"
      store="xvarStore"
      class="blurEvent" 
      value=""
      searchAttr="name"
      name="vehicle_1"
      id="vehicle_1"
    />

dojo.query(".blurEvent").forEach(function(node, index, arr) {
      dojo.connect(node, "onBlur", function() { /* do something */ });
  });

In the function that is passed to dojo.connect you could add in some code to strip out the number on the end and use it to reference each filter_value_* input for validation.

dojo.connect()

Combobox documention

onBlur seems to work just fine for me, even in the HTML-declared widgets. Here's a very rudimentary example:

http://jsfiddle.net/kfranqueiro/BWT4U/

(Have firebug/webkit inspector/IE8 dev tools open to see console.log messages.)

However, for a more ideal solution to this, you might also be interested in some other widgets...

Hopefully this can get you started.

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