Skip to content

Commit 7b03f59

Browse files
committed
Widget Factory: Fix data namespace and style issues
Fixes jquerygh-274
1 parent 903a245 commit 7b03f59

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

page/jquery-ui/widget-factory/how-to-use-the-widget-factory.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ alert( bar.progressbar( "value" ) );
110110

111111
### Working with Options
112112

113-
One of the methods that are automatically available to our plugin is the `option()` method. The `option()` method allows you to get and set options after initialization. This method works exactly like jQuery's `.css()` and `.attr()` methods: You can pass just a name to use it as a getter, a name and value to use it as a single setter, or a hash of name/value pairs to set multiple values. When used as a getter, the plugin will return the current value of the option that corresponds to the name that was passed in. When used as a setter, the plugin's `_setOption` method will be called for each option that is being set. We can specify a `_setOption` method in our plugin to react to option changes. For actions to perform independent of the number of options changed, we can override `_setOptions`.
113+
One of the methods that are automatically available to our plugin is the `option()` method. The `option()` method allows you to get and set options after initialization. This method works exactly like jQuery's `.css()` and `.attr()` methods: You can pass just a name to use it as a getter, a name and value to use it as a single setter, or a hash of name/value pairs to set multiple values. When used as a getter, the plugin will return the current value of the option that corresponds to the name that was passed in. When used as a setter, the plugin's `_setOption` method will be called for each option that is being set. We can specify a `_setOption` method in our plugin to react to option changes. For actions to perform independent of the number of options changed, we can override `_setOptions()`.
114114

115115
```
116116
$.widget( "custom.progressbar", {
@@ -219,7 +219,7 @@ Because the plugin instance is directly linked to the DOM element, you can acces
219219
var bar = $( "<div></div>" )
220220
.appendTo( "body" )
221221
.progressbar()
222-
.data( "progressbar" );
222+
.data( "custom-progressbar" );
223223
224224
// Call a method directly on the plugin instance.
225225
bar.option( "value", 50 );
@@ -251,7 +251,7 @@ For more information on extending widgets, including how to build entirely new w
251251

252252
### Cleaning Up
253253

254-
In some cases, it will make sense to allow users to apply and then later unapply your plugin. You can accomplish this via the `_destroy()` method. Within the `_destroy()` method, you should undo anything your plugin may have done during initialization or later use. `_destroy()` is called by the `.destroy()` method, which is automatically called if the element that your plugin instance is tied to is removed from the DOM, so this can be used for garbage collection as well. That base `.destroy()` method also handles some general cleanup operations, like removing the instance reference from the widget's DOM element, unbinding all events in the widget's namespace from the element, and unbinding generally all events that were added using `_bind()`.
254+
In some cases, it will make sense to allow users to apply and then later unapply your plugin. You can accomplish this via the `_destroy()` method. Within the `_destroy()` method, you should undo anything your plugin may have done during initialization or later use. `_destroy()` is called by the `destroy()` method, which is automatically called if the element that your plugin instance is tied to is removed from the DOM, so this can be used for garbage collection as well. That base `destroy()` method also handles some general cleanup operations, like removing the instance reference from the widget's DOM element, unbinding all events in the widget's namespace from the element, and unbinding generally all events that were added using `_bind()`.
255255

256256
```
257257
$.widget( "custom.progressbar", {

0 commit comments

Comments
 (0)