Topic
6 replies Latest Post - ‏2013-01-07T13:09:09Z by SystemAdmin
SystemAdmin
SystemAdmin
2327 Posts
ACCEPTED ANSWER

Pinned topic wlCommonInit called multiple times

‏2012-12-19T12:51:15Z |
Hi,

My function wlCommonInit() contains this :

// Worklight comes with the jQuery 1.8.1 framework bundled inside. If you do not want to use it, please comment out the line below.
window.$ = window.jQuery = WLJQ;
function wlCommonInit(){
// Common initialization code goes here
busyIndicator = new WL.BusyIndicator("AppBody");

getArticlesList();
}

The function getArticlesList() calls a SQLAdapter to retrieve datas from a database (mysql).

When i test on simulator, i can see on firebug (json response) that the data from getArticlesList() is loaded 3 times.
It seems that the wlCommmonInit is called 3 times. But why ?
Thanks.
  • IdanAdar
    IdanAdar
    741 Posts
    ACCEPTED ANSWER

    Re: wlCommonInit called multiple times

    ‏2012-12-20T10:18:20Z  in response to SystemAdmin
    Hi,

    It is difficult to answer this question as there is not much to go on. Can you attach your project?

    Idan Adar
    QA Engineer
    IBM Worklight Mobile Platform
    • SystemAdmin
      SystemAdmin
      2327 Posts
      ACCEPTED ANSWER

      Re: wlCommonInit called multiple times

      ‏2012-12-20T09:02:09Z  in response to IdanAdar
      Hi,

      I attached my project.
      I removed some directories that were generated by worklight (dojo librairies, native android, ...).

      Thanks for your help.
  • IdanAdar
    IdanAdar
    741 Posts
    ACCEPTED ANSWER

    Re: wlCommonInit called multiple times

    ‏2012-12-20T10:21:59Z  in response to SystemAdmin
    Unfortunately I am encountering various errors once importing the project due to the removal of the dojo folders.

    Does this happen to you with a regular Worklight Hybrid application (w/out Dojo)?
    I am not a Dojo expert; hopefully our resident Dojo expert will get to this post soon...

    Idan Adar
    QA Engineer
    IBM Worklight Mobile Platform
    • SystemAdmin
      SystemAdmin
      2327 Posts
      ACCEPTED ANSWER

      Re: wlCommonInit called multiple times

      ‏2012-12-20T11:13:48Z  in response to IdanAdar
      Yes, this happen with a regular Worklight Hybrid application and without Dojo.
      When i created the project, i checked "Add Dojo Toolkit" and "Add jQuery Mobile".
      But the dojo library is not used in the project.

      I attached a new project with AndroidManifest.xml and project.properties in the native directory (android) because it generate errors when deploying.

      There is an sql directory which contains a sql file to create the database.

      I can provide others informations if necessary
      • raanan
        raanan
        50 Posts
        ACCEPTED ANSWER

        Re: wlCommonInit called multiple times

        ‏2012-12-23T13:52:55Z  in response to SystemAdmin
        When you add jQuery and jQuery Mobile and Dojo together in the same application they will create multiple event listener that will fire on document ready simultaneously and will create general mayhem. Do not do that.
        • SystemAdmin
          SystemAdmin
          2327 Posts
          ACCEPTED ANSWER

          Re: wlCommonInit called multiple times

          ‏2013-01-07T13:09:09Z  in response to raanan
          Sorry to reply so late...

          I found where the problem comes from.
          It's not Dojo because i recreated the projet without it and the problem was still here.

          The problem is jQuery Mobile.
          When i removed it, it works (there is only one call to the wlCommonInit function).

          I tested with different version of jquery mobile (1.2.0, 1.1.1 and 1.0.1) and without success.