What is a good way of filling a form in ExtJS by code, and fire the events for each component as if they were filled by the user?

瘦欲@ 提交于 2019-12-11 04:21:28

问题


In the project I'm working on, I have forms I sometimes have to fill by code.

Let's say I have two comboboxes : combo1 and combo2. They are both required by default (allowBlank : false). On combo1's select event, I set combo2's allowBlank property to true and clear it. Everything's good so far, while user is filling the form.

When I use combo1's setValue method, it doesn't trigger the select event, so combo2 is still required when I don't want it to be. What is a good way to solve this problem? Should I fire the events manually after setting values?


回答1:


Yes, you need to trigger the events manually.

No UI events are triggered with JavaScript. This is to prevent endless loops and other undesired side-effects while interacting with the page programmatically.

In ExtJS, there is component.fireEvent(...) for that purpose.



来源:https://stackoverflow.com/questions/4591625/what-is-a-good-way-of-filling-a-form-in-extjs-by-code-and-fire-the-events-for-e

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