$('.mySelectMenu').selectmenu('refresh', true);Sometime we might get an error like: "Uncaught cannot call methods on selectmenu prior to initialization; attempted to call method 'refresh'". To resolve it by first initialize the select menu and then refreshing it.
$('.mySelectMenu').selectmenu();20 Nov 2012: Update with JQM 1.2.0 code explanation given below.
$('.mySelectMenu').selectmenu('refresh', true);
Make sure that the selector returns items which are all select nodes. Otherwise JQM will throw the above mentioned error. See the below JQM code.
// jQM v1.2.0: line 516The code at line 6 checks for
// ...
if ( isMethodCall ) {
this.each(function() {
var methodValue,
instance = $.data( this, fullName );
if ( !instance ) {
return $.error( "cannot call methods on " + name + " prior to initialization; " +
"attempted to call method '" + options + "'" );
}
// ...
});
}
// ...
mobileSelectmenu
property in the current element and assigns to the instance
variable. If the current item is not select
then the instance
is null
and we get the error.