selectmenu ('refresh', true)

Dar Lym picture Dar Lym · May 11, 2012 · Viewed 26.6k times · Source

I get form from zend framework site and put it in response in new file in function written by jquery mobile, but I get this error:

uncaught exception: cannot call methods on selectmenu prior to initialization; attempted to call method 'refresh' .

Code of function this file:

     function addItem(id) {
        $.ajax({
            url:'http://zf.darina.php.nixsolutions.com/order/index/create-order-mobile',
            dataType:"jsonp",
            data:{id_good:id},
            success:function (resp) {

                console.log(resp);
                $('.product-table').empty();

                $('.product-table').append(resp.prod);
                $('.product-table').append(resp.form);
                $('.add-order-btn').button();

                $('.mob-size').selectmenu('refresh', true);

                $('#block').page();
            }
        })
    }

Answer

HoffZ picture HoffZ · Oct 9, 2012

Force initialize the selectmenu(s) first:

$('.mob-size').selectmenu(); // Initializes
$('.mob-size').selectmenu('refresh', true);

or use this for short

$('.mob-size').selectmenu().selectmenu('refresh', true);