Dojo:dojo onblur事件 [英] Dojo: dojo onblur events

查看:148
本文介绍了Dojo:dojo onblur事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用dojo 1.5的表单设置。我正在使用一个dijit.form.ComboBox和一个dijit.form.TextBox



组合框有像汽车,自行车,摩托车和文本框是组合框的形容词。
因此,Combobox中的内容并不重要,但如果ComboBox确实有一个值,那么必须在TextBox中填充一些东西。可选地,如果ComboBox中没有任何内容,则TextBox中的任何内容都可以,而且这样也不错。事实上,如果某些东西不在组合框中,那么文本框中就不会有任何东西。



在常规编码中,我只需在文本框上使用onBlur事件即可到一个函数,检查ComboBox是否有一个值。我在dojo看到这不工作...代码示例在下面...

 车辆:
< input dojoType =dijit.form.ComboBox
store =xvarStore
value =
searchAttr =name
name =vehicle_1
id =vehicle_1
/>
描述符:
< input type =text
dojoType =dijit.form.TextBox
value =
class = lighttext
style =width:350px; height:19px
id =filter_value_1
name =filter_value_1
/>

我最初的尝试是在Descriptor的< input>中添加一个onBlur标签,但发现那不起作用。



Dojo如何处理?是通过dojo.connect参数吗?即使在上面的示例中,组合框的ID为车辆__1,文本框的ID为filter_value_1,可以有许多组合框和文本框顺序向上编号。 (vehicle_2,vehicle_3等)



任何对资源的建议或链接都​​将不胜感激。 Janie

解决方案

要添加onBlur事件,您应该使用dojo.connect():

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

如果您需要连接多个输入,请考虑为那些需要模糊并使用dojo.query连接到所有这些:

 车辆:
<输入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某事* /});
});

在传递给dojo.connect的函数中,可以添加一些代码来删除数字最后使用它引用每个filter_value_ *输入进行验证。



dojo.connect()



组合框文档


I have a form setup with dojo 1.5. I am using a dijit.form.ComboBox and a dijit.form.TextBox

The Combobox has values like "car","bike","motorcycle" and the textbox is meant to be an adjective to the Combobox. So it doesn't matter what is in the Combobox but if the ComboBox does have a value then something MUST be filled in the TextBox. Optionally, if nothing is in the ComboBox, then nothing can be in the TextBox and that is just fine. In fact if something isn't in the Combobox then nothing MUST be in the text box.

In regular coding I would just use an onBlur event on the text box to go to a function that checks to see if the ComboBox has a value. I see in dojo that this doesn't work... Code example is below...

Vehicle:
    <input dojoType="dijit.form.ComboBox"
      store="xvarStore"
      value=""
      searchAttr="name"
      name="vehicle_1"
      id="vehicle_1"
    />
 Descriptor:
<input type="text"
                dojoType="dijit.form.TextBox"
                value=""
                class=lighttext
                style="width:350px;height:19px"
                id="filter_value_1"
                name="filter_value_1"
                />

My initial attempt was to add an onBlur within the Descriptor's <input> tag but discovered that that doesn't work.

How does Dojo handle this? Is it via a dojo.connect parameter? Even though in the example above the combobox has an id of "vehicle_1" and the text box has an id of "filter_value_1", there can be numerous comboboxes and textboxes numbering sequentially upward. (vehicle_2, vehicle_3, etc)

Any advice or links to resources would be greatly appreciated. Janie

解决方案

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

这篇关于Dojo:dojo onblur事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆