jQuery Mobile rendering problems with content being added after the page is initialized

后端 未结 11 1998
清酒与你
清酒与你 2020-12-14 18:54

I\'m using jQuery Mobile and Backbone JS for a project. It\'s mostly working, using jQuery Mobile\'s event \'pagebeforeshow\' to trigger the correct Backbone View. In the Ba

11条回答
  •  情话喂你
    2020-12-14 19:12

    I'm not sure if this helps but when adding dynamic elements I was using .page() in the sucess ajax call itself (example here and here) but I found that it was not working as expected. I found that in the ajax call it's better to refresh the element (if it's a form element) to use these documented methods:

    • Checkboxes:

      $("input[type='checkbox']").attr("checked",true).checkboxradio("refresh");
      
    • Radios:

      $("input[type='radio']").attr("checked",true).checkboxradio("refresh");
      
    • Selects:

      var myselect = $("select#foo");
      myselect[0].selectedIndex = 3;
      myselect.selectmenu("refresh");
      
    • Sliders:

      $("input[type=range]").val(60).slider("refresh");
      
    • Flip switches (they use slider):

      var myswitch = $("select#bar");
      myswitch[0].selectedIndex = 1;
      myswitch .slider("refresh");
      

    and for adding a non-form element use .page()

提交回复
热议问题