在切换“禁用”时刷新 css通过 javascript 获取 dijit 小部件的属性

发布于 2025-01-07 00:47:10 字数 124 浏览 0 评论 0原文

我正在更改用户某些操作的一些 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

伴梦长久 2025-01-14 00:47:10

我正在做类似的事情

widget.disabled = (condition)?"disabled":"";

(实际上我的代码不同,但它执行类似的功能。)

这是因为 dijit 小部件无法知道代码何时直接更改属性。遗憾的是我直接这样做了,而不是使用 set API(这仅特定于 dijit 小部件,也许我应该将我的问题更改为具体?)。

widget.set("disabled", condition);

我还通过执行 dojo.removeClass(widget, "dijitDisabled"); (有很多“禁用”状态的类)获得了成功,但这种方法很幼稚,最后我得到了上述解决方案这是好的、标准的、简洁的。

I was doing something like

widget.disabled = (condition)?"disabled":"";

(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?).

widget.set("disabled", condition);

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.

够钟 2025-01-14 00:47:10

您可以在 UI 发生特定操作时调用 JS 方法。
我通过以下方式做到了这一点:

  function disablewidget{
      if (navigator.appName == "Microsoft Internet Explorer") {
          var child = document.getElementById("id_of_your_widget");
          child.setAttribute("className", "disabled_class");
      }
      else{
          document.getElementById("id_of_your_widgets").className = "disabled_class";
      }
}

这里 disabled_class 是我在 css 文件中定义的一个类,其中包含操作,当我想向用户显示禁用元素(更改背景等)时,我需要执行..)

希望这有帮助。

You can call JS method while particular actions occur from UI.
I did this in following way :

  function disablewidget{
      if (navigator.appName == "Microsoft Internet Explorer") {
          var child = document.getElementById("id_of_your_widget");
          child.setAttribute("className", "disabled_class");
      }
      else{
          document.getElementById("id_of_your_widgets").className = "disabled_class";
      }
}

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文