Topic
10 replies Latest Post - ‏2012-12-06T14:03:07Z by AntonAleksandrov
Paramasivan.G
Paramasivan.G
33 Posts
ACCEPTED ANSWER

Pinned topic Error : WL is undeined

‏2012-11-29T06:28:06Z |
Hi,

I am Working on Worklight 5.0.0.3. and using jQuery Mobile UI in my html pages.I am not able to use any WL methods say invoking adapter. while trying that used to get error "WL is undeined"

Kindly help me with the Work around

PFA for my Sample App

Thanks
Paramasivan G
  • SystemAdmin
    SystemAdmin
    2327 Posts
    ACCEPTED ANSWER

    Re: Error : WL is undeined

    ‏2012-11-29T07:26:44Z  in response to Paramasivan.G
    U have to do some changes....

    first define in main html page...
    <script>
    var jq = jQuery.noConflict();
    </script>

    then in project.js include this

    window.$ = window.jQuery = WLJQ;
    function wlCommonInit() {
    jq.mobile.changePage("#Login");

    }

    Dont forgot to include ur js file in ur html page
    • Paramasivan.G
      Paramasivan.G
      33 Posts
      ACCEPTED ANSWER

      Re: Error : WL is undeined

      ‏2012-11-29T10:12:26Z  in response to SystemAdmin
      Hi PraveenBabu ,

      Even after adding the code as you specified Still i'm getting the same error.
      Thanks

      Paramasivan G
      • SystemAdmin
        SystemAdmin
        2327 Posts
        ACCEPTED ANSWER

        Re: Error : WL is undeined

        ‏2012-11-29T11:10:45Z  in response to Paramasivan.G
        See my reply here:
        https://www.ibm.com/developerworks/forums/message.jspa?messageID=14906205#14906205

        page2.html does not have the the script tags that define the WL namespace.
        • Paramasivan.G
          Paramasivan.G
          33 Posts
          ACCEPTED ANSWER

          Re: Error : WL is undeined

          ‏2012-11-30T06:59:44Z  in response to SystemAdmin
          Hi cnandreu

          I went through this post, Even in my files I've got all the references as specified in your post. But still i'm not able to implement or invoke any of the WL methods. Is there a fix for this problem???

          Kindly let me know the work around.

          Thanks
          Paramasivan G
          • raanan
            raanan
            50 Posts
            ACCEPTED ANSWER

            Re: Error : WL is undeined

            ‏2012-12-02T06:48:34Z  in response to Paramasivan.G
            Hi Paramasivan.

            A Worklight application is a Single Page Application (SPA).
            In your application there is a <application name>.html file.
            Do you stay on this file or do you navigate to other URLs?
            Anyway, we need more information about the error you get, so try this:
            In the same project create a new application.
            In the new application in the in wlCommonInit function write WL.Logger.debug('Hello World');
            Run a preview of the application.
            Do you see it in the browser console?
            Add to the application jQuery Mobile. Do the same.
            • Paramasivan.G
              Paramasivan.G
              33 Posts
              ACCEPTED ANSWER

              Re: Error : WL is undeined

              ‏2012-12-03T03:21:05Z  in response to raanan
              Hi raanan ,

              As you mentioned i traverse to different pages from the main page. Also i get this error only when i add the jQuery Mobile reference to my hybrid application. Ordinarily without jQuery Mobile reference the app works fine and i'm able to use all the WL methods.
              • raanan
                raanan
                50 Posts
                ACCEPTED ANSWER

                Re: Error : WL is undeined

                ‏2012-12-03T07:16:35Z  in response to Paramasivan.G
                Hi.

                I want you to do anther test.
                Add to the project a jQuery file and remove the windows.$ = windows.jQuery = WLJQ; line and try your application.
                • Paramasivan.G
                  Paramasivan.G
                  33 Posts
                  ACCEPTED ANSWER

                  Re: Error : WL is undeined

                  ‏2012-12-03T09:39:47Z  in response to raanan
                  Hi Raanan,

                  WL Methods are working in the <application name>.html page. It's not working only in the other pages as i traverse from <application name>.html page.

                  It'd be grateful if you specify a workaround for this issue.

                  Thanks
                  Paramasivan G
                  • Paramasivan.G
                    Paramasivan.G
                    33 Posts
                    ACCEPTED ANSWER

                    Re: Error : WL is undeined

                    ‏2012-12-06T06:10:39Z  in response to Paramasivan.G
                    Still i've this problem.. Is there any fix available for this issue or shall i assume that Worklight Will not support with jQuery mobile when using multiple pages.
                    • AntonAleksandrov
                      AntonAleksandrov
                      55 Posts
                      ACCEPTED ANSWER

                      Re: Error : WL is undeined

                      ‏2012-12-06T14:03:07Z  in response to Paramasivan.G
                      Worklight works with jQuery Mobile. You can download a sample project here - http://public.dhe.ibm.com/ibmdl/export/pub/software/mobile-solutions/worklight/docs/WorklightStarter_jQueryMobile.zip
                      In case this does not help - please create a small project that allows to replicate your issue and post it, we will take a look.