Thursday, June 14, 2012

jQuery Mobile Select Menu

Had a bit of a headache today trying to figure out how to dynamically load a select menu using ajax with jQuery Mobile. The select menu would load fine, but I was losing all of the styling. Thanks to a post from kadaj's musing I realized that I needed to initialize the select menu before I tried to refresh it.

$('#selectMenu').selectmenu();
$('#selectMenu').selectmenu('refresh', true);

This method helped me avoid the "Uncaught cannot call methods on selectmenu prior to initialization; attempted to call method 'refresh'" error I was getting.

No comments:

Post a Comment