jquery ui
We're all used to passing options when instantiating an object, whether it be JavaScript or any other language. Whether or not you can update those options later is usually up to the framework, and somehow many wont let you update them once they've been passed in. Depending on how the initialization of the object is done, sometimes that makes sense, but in most cases you should be able to update an option at any given time.
实例化对象时,无论是JavaScript还是其他任何语言,我们都习惯于传递选项。 以后是否可以更新这些选项通常取决于框架,并且某种程度上,一旦传递了它们,您将不让您对其进行更新。这取决于对象的初始化方式,有时候这很有意义,但是大多数情况下,您应该可以在任何给定时间更新选项。
I recently needed to update a jQuery UI widget option and here's how you update any given option:
我最近需要更新jQuery UI窗口小部件选项,以下是更新任何给定选项的方法:
this.$editor.inlineEditor('option', 'forceOpen', true);
jQuery UI is mostly a legacy technology these days so I'm mostly passing this tip on for those having to maintain old code. This does teach a good lesson: always provide a method for modifying initial options, even if you don't foresee a reason to do so!
如今,jQuery UI主要是一种遗留技术,因此我主要将这些技巧传递给那些必须维护旧代码的人。 这确实教了一个很好的教训:即使您没有预料到这样做的理由,也要始终提供一种修改初始选项的方法!
jquery ui