1

I'm trying to follow this guide. I reach a problem when i try to change the HTML file when the user clicks a button.

This is my script:

<script>
        window.$ = window.jQuery = WLJQ;
        $("#btnPromo").click(function(){
            $("#pagePort").load("pages/MainPage.html", function(){
                alert("loaded!");
            });
        });
    </script>

And this is my core HTML file (auto generated by Worklight):

<body onload="WL.Client.init({})" id="content" style="display: none;">
<!--application UI goes here-->
<div data-role="page" id="pagePort">
    <div id="header" align="center">
        <img src="images/logo.png">
    </div>

    <div data-role="content">
        <div>
            <input type="image" name="btnPromo" src="images/btnHotPromo.png" width="75%"/>
        </div>
        <div>
            <input type="image" name="btnMall" src="images/btnMall.png" width="75%"/>
        </div>
        <div>
            <input type="image" name="btnOutlet" src="images/btnOutlet.png" width="75%"/>
        </div>
        <div>
            <input type="image" name="btnAbout" src="images/btnAbout.png" width="75%"/>
        </div>
    </div>
</div>

My goal is to change the #pagePort to MainPage.html every time the user clicks on #btnPromo.

Idan Adar
  • 44,156
  • 13
  • 50
  • 89
Blaze Tama
  • 10,828
  • 13
  • 69
  • 129

1 Answers1

1

The answer is i forgot to add the $(function(){}); at the start of the code, so the code should be :

$(function(){
        $("#btnPromo").click(function(){
            $("#pagePort").load("pages/MainPage.html", function(){
                alert("loaded!");
            });
        });
});

And everything will be OK :D

Blaze Tama
  • 10,828
  • 13
  • 69
  • 129