在切换“禁用”时刷新 css通过 javascript 获取 dijit 小部件的属性
我正在更改用户某些操作的一些 dijit 的禁用属性。它可以工作,但小部件的 css 不会更新,除非将鼠标悬停在其上,或者基本上触发小部件上的任何事件。我该如何解决这个问题?我错过了或者做错了什么吗? 我使用的是火狐8.0.1浏览器。
I am changing the disabled attribute of a number of dijits on users' certain actions. Its works but the css of the widgets doesn't get updated, unless being hovered over, or basically triggering any event on the widget. How can I fix this? Am I missing or doing anything wrong?
I am using Firefox 8.0.1 browser.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我正在做类似的事情
(实际上我的代码不同,但它执行类似的功能。)
这是因为 dijit 小部件无法知道代码何时直接更改属性。遗憾的是我直接这样做了,而不是使用
set
API(这仅特定于 dijit 小部件,也许我应该将我的问题更改为具体?)。我还通过执行
dojo.removeClass(widget, "dijitDisabled");
(有很多“禁用”状态的类)获得了成功,但这种方法很幼稚,最后我得到了上述解决方案这是好的、标准的、简洁的。I was doing something like
(Actually my code is different but it was doing similar functionality.)
This was caused because the dijit widget couldn't know when the code changed an attribute directly. My bad that I did it directly instead of using the
set
API(This is specific to dijit widgets only, perhaps I should change my question to be specific?).I also got success by doing
dojo.removeClass(widget, "dijitDisabled");
(with a lots of classes for 'disabled' state), but this approach is naive and finally I got the above mentioned solution which is good, standard, and concise.您可以在 UI 发生特定操作时调用 JS 方法。
我通过以下方式做到了这一点:
这里
disabled_class
是我在 css 文件中定义的一个类,其中包含操作,当我想向用户显示禁用元素(更改背景等)时,我需要执行..)希望这有帮助。
You can call JS method while particular actions occur from UI.
I did this in following way :
Here the
disabled_class
is a class which I have defined in css file with the actions, I need to perform when I want to show a disabled element to user (changing the background etc..)Hope this helps.