문제

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...

도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top