Question

Previously for custom widgets I used code like this:

var bar = $( "<div />")
    .appendTo( "body" )
    .progressbar()
    .data( "progressbar" );

but with jQuery UI 1.10 this code doesn't work any more... data("progressbar") doesn't return anything.

I tested it with the widget example from http://learn.jquery.com/plugins/stateful-plugins-with-widget-factory/ where the widget has name with namespace "nmk.progressbar"

In the upgrade guide from jQuery 1.9 to 1.10 I found this: http://jqueryui.com/upgrade-guide/1.9/#changed-naming-convention-for-data-keys but still have no idea what I should change in order get it working back...

Was it helpful?

Solution

You need to add a prefix ui- to the previous key like ui-progressbar.

From Doc

Widget instances now use the full name, including the namespace, e.g., ui-dialog instead of dialog

Use

var bar = $( "<div />")
    .appendTo( "body" )
    .progressbar()
    .data( "ui-progressbar" );

Demo: Fiddle

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top