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.

  One Response to “jquerymobile cannot call methods on listview prior to initialization”

  1. Just a heads up, most of that code for the require.paths is to enruse using the specific version of the modules listed by having them included inside a project, rather than just pulling them in globally (libraries are changing node is growing are fair reasons to do this in production). If you install global libraries it can sometimes override the dependency for some things, however, most of the time npm can solve this issue if you do not want to check / use a specific version of a module.Unfortunately, the error that is being thrown is coming from the mongodb-native module not being installed, that is a prerequisite for mongoose. So, when it tries to compile mongoose, it dies inside of the compile since the mongodb module was not available globally.

Sorry, the comment form is closed at this time.

   
© 2012 Craig Brookes Suffusion theme by Sayontan Sinha