I’ve been writing a lot of javascript lately. Lots of nodejs and also sencha touch and jquerymobile.

I ran across a very frustrating error in jquerymobile the other day when injecting a list into the dom.

From jquerymobile docs it says you should call $(‘#mylist’).listview(‘refresh’);
However when I did this I got the error jquerymobile cannot call methods on listview prior to initialization. This is a very annoying error and it seems that jquerymobile has overlooked injecting content into the dom and restyling it, as from my google searches, it appears to be a common problem.

Here is my solution:

after injecting call:

 $('#mylist').listview(); 
 $('#mylist').listview('refresh');
  

Seems simple but I thought I would share this info as it caused quite a lot of pain before discovering the solution.

© 2012 Craig Brookes Suffusion theme by Sayontan Sinha