jquery mobile“.click”事件未执行

发布于 2024-11-08 18:26:33 字数 4258 浏览 0 评论 0原文

基本上indexPage是根页面。单击个人资料时,应该打开个人资料页面。 profilePage 上的按钮无法触发单击事件。

索引页:

<div data-role="page" data-theme="b" id="indexPage">
        <div data-role="header" data-theme="b" class="toolbar">
            <h1>Smart Meter</h1>
             <a href="#login" data-rel="dialog" data-transition="pop" class="ui-btn-right">Login</a>
            <!-- <div data-role="navbar"data-theme="b"> -->

        <!-- </div><!-- /navbar -->
     </div>

        <div id="content" data-role="content">
            <table align="center" class="iconGrid">

                    <tr>
                        <td>
                            <a href="#profile"  id="liProfile" data-iconpos="top"  data-role="button" data-icon="custom" data-transition="slide"  data-rel="dialog">Profile</a>
                        </td>

                        <td>
                            <a  href="#appliance" id="liAppliance" data-iconpos="top" data-role="button" data-icon="custom" data-transition="slide" data-rel="dialog">Appliance</a>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <a href="#schedule" id="liSchedule" data-iconpos="top" data-role="button" data-icon="custom" data-transition="slide" data-rel="dialog">Schedule</a>
                        </td>

                        <td>
                            <a href="#consumption" id="liConsumption" data-iconpos="top" data-role="button" data-icon="custom" data-transition="slide" data-rel="dialog">Schedule</a>
                        </td>
                    </tr>




            </table>

        </div>

简介页:

<div data-role="page" id="profilePage">

            <div data-role="header">
                <h1>Page Title</h1>
            </div><!-- /header -->

            <div data-role="content">           

                <div data-role="fieldcontain">
                 <label for="name">Name :</label>
                 <input type="text" name="name" id="name" value=""  />
                </div>

                <div data-role="fieldcontain">
                 <label for="password">password :</label>
                 <input type="password" name="password" id="password" value=""  />
                </div>

                <div data-role="fieldcontain">
                 <label for="mobileNo">Mobile No. :</label>
                 <input type="text" name="mobileNo" id="mobileNo" value=""  />
                </div>

                <div data-role="fieldcontain">
                 <label for="email">Email Address :</label>
                 <input type="text" name="email" id="email" value=""  />
                </div>

                <div data-role="fieldcontain">
                 <label for="address">Address :</label>
                 <input type="text" name="address" id="address" value=""  />
                </div>

                <div data-role="fieldcontain">
                 <label for="tariff">Tariff :</label>
                 <input type="text" name="tariff" id="tariff" value=""  />
                </div>

                <div data-role="fieldcontain">
                 <label for="budget">Budget :</label>
                 <input type="text" name="budget" id="budget" value=""  />
                </div>

                <div align="center" style="width:100px;" id="save">
                <div id="message"></div>
                <a href="#" id="btnSave" data-role="button">Save</a>
            </div>  



            </div><!-- /content -->

            <div data-role="footer">
                <h4>Page Footer</h4>
            </div><!-- /footer -->

        </div><!-- /page -->

basically the indexPage is the root page. When clicked on the profile it's supposed to open up profilePage. A button that is on profilePage cannot trigger the click event.

IndexPage:

<div data-role="page" data-theme="b" id="indexPage">
        <div data-role="header" data-theme="b" class="toolbar">
            <h1>Smart Meter</h1>
             <a href="#login" data-rel="dialog" data-transition="pop" class="ui-btn-right">Login</a>
            <!-- <div data-role="navbar"data-theme="b"> -->

        <!-- </div><!-- /navbar -->
     </div>

        <div id="content" data-role="content">
            <table align="center" class="iconGrid">

                    <tr>
                        <td>
                            <a href="#profile"  id="liProfile" data-iconpos="top"  data-role="button" data-icon="custom" data-transition="slide"  data-rel="dialog">Profile</a>
                        </td>

                        <td>
                            <a  href="#appliance" id="liAppliance" data-iconpos="top" data-role="button" data-icon="custom" data-transition="slide" data-rel="dialog">Appliance</a>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <a href="#schedule" id="liSchedule" data-iconpos="top" data-role="button" data-icon="custom" data-transition="slide" data-rel="dialog">Schedule</a>
                        </td>

                        <td>
                            <a href="#consumption" id="liConsumption" data-iconpos="top" data-role="button" data-icon="custom" data-transition="slide" data-rel="dialog">Schedule</a>
                        </td>
                    </tr>




            </table>

        </div>

profilePage :

<div data-role="page" id="profilePage">

            <div data-role="header">
                <h1>Page Title</h1>
            </div><!-- /header -->

            <div data-role="content">           

                <div data-role="fieldcontain">
                 <label for="name">Name :</label>
                 <input type="text" name="name" id="name" value=""  />
                </div>

                <div data-role="fieldcontain">
                 <label for="password">password :</label>
                 <input type="password" name="password" id="password" value=""  />
                </div>

                <div data-role="fieldcontain">
                 <label for="mobileNo">Mobile No. :</label>
                 <input type="text" name="mobileNo" id="mobileNo" value=""  />
                </div>

                <div data-role="fieldcontain">
                 <label for="email">Email Address :</label>
                 <input type="text" name="email" id="email" value=""  />
                </div>

                <div data-role="fieldcontain">
                 <label for="address">Address :</label>
                 <input type="text" name="address" id="address" value=""  />
                </div>

                <div data-role="fieldcontain">
                 <label for="tariff">Tariff :</label>
                 <input type="text" name="tariff" id="tariff" value=""  />
                </div>

                <div data-role="fieldcontain">
                 <label for="budget">Budget :</label>
                 <input type="text" name="budget" id="budget" value=""  />
                </div>

                <div align="center" style="width:100px;" id="save">
                <div id="message"></div>
                <a href="#" id="btnSave" data-role="button">Save</a>
            </div>  



            </div><!-- /content -->

            <div data-role="footer">
                <h4>Page Footer</h4>
            </div><!-- /footer -->

        </div><!-- /page -->

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

断舍离 2024-11-15 18:26:33
<a href="#" id="btnSave" data-role="button">Save</a>



    $("#btnSave").click(function(e){
        e.preventDefault();
        alert("btnSave is clicked");
        return false;
        });
<a href="#" id="btnSave" data-role="button">Save</a>



    $("#btnSave").click(function(e){
        e.preventDefault();
        alert("btnSave is clicked");
        return false;
        });
呆° 2024-11-15 18:26:33

将所有 JavaScript 移至所有页面的索引(根页面)。因此,如果 page2 有一些 JavaScript,请将其移动到索引(根)页面。

这是一个工作示例: http://jsfiddle.net/3VnLr/2/

注意我正在使用多页面布局,但所有 JavaScript 都在同一页面上(索引或根)

Move all JavaScript to the index (root page) for all pages. So if page2 has some JavaScript move it to the index (root) page.

Here is a working example: http://jsfiddle.net/3VnLr/2/

Note I am using the multi page layout but all the JavaScript is on the same page (index or root)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文