jQTouch 动态网络应用程序?

发布于 2024-09-17 19:18:55 字数 5732 浏览 2 评论 0原文

我正在开发一个动态变化的网络应用程序。我使用 javascript 和 jQuery 用

  • 填充 DIV。例如,我从使用 JavaScript 动态构建的一个菜单开始。从该菜单中,根据所选项目,将调用另一个 javascript 函数来动态填充相应的 DIV。当我不断动态构建子菜单并且 JQTouch 不切换到下一页时,问题就出现了。
  • 在以下代码中,alert('what') 显示在 iPhone 上,但从未切换到 ePresentationDetails DIV。我尝试用 jQT.goTo(); 强制它但这通常会导致更多问题,并且不能解决问题。

    基本 html 代码:

         <div id="home">
            <div class="toolbar">
                <a class="blueButton" href="javascript: void(0);" onClick="$('#logout').show();">Logout</a>
                <h1>AllaccessMD</h1>
            </div>
            <div id="logout" style="display:none;">
                <div id="confirmBox">
                    Are you sure?
                    <a class="logoutButton" href="javascript: void(0);" onClick="logOut();">Logout</a>
                    <a class="cancelButton" href="javascript: void(0);" onClick="$('#logout').hide();">Cancel</a>
                </div>
            </div>
            <h1>Home</h1>
            <ul class="edgetoedge" id="ulHome"></ul>
        </div>
        <div id="ePresentations">
            <div class="toolbar">
                <a class="button back" href="#">Back</a>
                <h1>AllaccessMD</h1>
            </div>
            <div id="ePresentationsData"><div class="progress"><font style="padding-right:5px;">Loading...</font><img border="0" src="Images/ajax-loader.gif" /></div>
            </div>
        </div>
        <div id="ePresentationDetails">
            <div class="toolbar">
                <a class="button back" href="#">Back</a>
                <h1>AllaccessMD</h1>
            </div>
            <div id="ePresentationDetailsData"><div class="progress"><font style="padding-right:5px;">Loading...</font><img border="0" src="Images/ajax-loader.gif" /></div>
            </div>
        </div>
    

    Javascript 文件:

    function setupHome(){
    if(localStorage.role == "Specialist"){
        var homeUL = '<li class="arrow"><a id="aEP" rel="s,' + localStorage.userID + '" href="#ePresentations">My E-Presentation</a></li>'
                + '<li class="arrow"><a id="aN" rel="s,' + localStorage.userID + '" href="#date">My Newsletter</a></li>'
                + '<li class="arrow"><a id="aE" rel="s,' + localStorage.userID + '" href="#date">My Events</a></li>'
                + '<li class="arrow"><a id="aMP" rel="s,' + localStorage.userID + '" href="#date">Medical Partners</a></li>'
                + '<li class="arrow"><a id="aS" rel="s,' + localStorage.userID + '" href="#date">Search</a></li>'
                + '<li class="arrow"><a id="aP" rel="s,' + localStorage.userID + '" href="#date">Profile</a></li>';
        $('#ulHome').html(homeUL);
    } else {
        var homeUL = '<li class="arrow"><a id="aMP" rel="m,' + localStorage.userID + '" href="#date">Medical Partners</a></li>'
                + '<li class="arrow"><a id="aS" rel="m,' + localStorage.userID + '" href="#date">Search</a></li>'
                + '<li class="arrow"><a id="aP" rel="m,' + localStorage.userID + '" href="#date">Profile</a></li>';
        $('#ulHome').html(homeUL);
    }
    $('#ePresentations').bind('pageAnimationStart', function (e){setupEPresentations(getID($('#aEP').attr('rel')).id);});
    }
    function setupEPresentations(sID){
    xmlhttp.onreadystatechange = function() {
        if (xmlhttp.readyState==4 && xmlhttp.status==200) {
            var epObject = JSON.parse(xmlhttp.responseText);
            var html = '<h1>Dr. ' + epObject.DR.DATA[0][1] + ' E-Presentation\'s</h1>';
            if(epObject.EP.DATA.length == 0){
                html += '<div><p>There are currently no E-Presentation\'s for this doctor.</p></div>';
            } else {
                html += '<ul class="edgetoedge">';
                for(var i in epObject.EP.DATA){
                    html += '<li class="arrow"><a id="' + epObject.EP.DATA[i][0] + '" href="#ePresentationDetails">' + epObject.EP.DATA[i][1] + '</a></li>';
                }
                html += '</ul>';
            }
            $('#ePresentationsData').html(html);
    
            $('#ePresentationsData li a').click(function(e)   {alert('what');setupEPresentationDetails(this.id);});
        }
    }
    xmlhttp.open("GET","Lib/ePresentations.cfm?Type=getAllEPsID&sID=" + sID,true);
    xmlhttp.send();
    }
    function setupEPresentationDetails(id){
    /*xmlhttp.onreadystatechange = function() {
        if (xmlhttp.readyState==4 && xmlhttp.status==200) {
            var epObject = JSON.parse(xmlhttp.responseText);
            var html = '<h1>Dr. ' + epObject.DATA[0][0] + ' E-Presentation</h1>';
            html += '<p>';
            //html += '<br />' + epObject.DATA[0][2].format("mmmm dd, yyyy");
            html += '<br /><strong>Rating:</strong> ' + Math.ceil(epObject.DATA[0][4]) + ' / 5 (' + epObject.DATA[0][5] + ' votes cast)';
            html += '<br /><br /><a rel="external" href="http://www.youtube.com/v/' + epObject.DATA[0][3] + '">Click here to view E-Presentation</a>';
            html += '</p>';
            $('#ePresentationDetailsData').html(html);
        }
    }
    xmlhttp.open("GET","Lib/ePresentations.cfm?Type=getEP&id=" + id,true);
    xmlhttp.send();*/
    $('#ePresentationDetailsData').html('I dont get called?');
     }
    

    我做错了什么?也许有更好的方法来做到这一点?

    谢谢!!

    I'm working on a dynamically changing web app. I'm using javascript and jQuery to populate DIV's with <li>'s and <a>'s. For example, I start with one menu dynamically built with javascript. From that menu, depending on item selected, another javascript function gets called to dynamically populate the corresponding DIV. The problem coming when I keep dynamically building submenu's and JQTouch doesn't switch to the next page.

    In the following code, the alert('what') displays on an iPhone but never switches to the ePresentationDetails DIV. I have tried forcing it with jQT.goTo(); but that usually causes more issues and doesn't fix the problem.

    Basic html code:

         <div id="home">
            <div class="toolbar">
                <a class="blueButton" href="javascript: void(0);" onClick="$('#logout').show();">Logout</a>
                <h1>AllaccessMD</h1>
            </div>
            <div id="logout" style="display:none;">
                <div id="confirmBox">
                    Are you sure?
                    <a class="logoutButton" href="javascript: void(0);" onClick="logOut();">Logout</a>
                    <a class="cancelButton" href="javascript: void(0);" onClick="$('#logout').hide();">Cancel</a>
                </div>
            </div>
            <h1>Home</h1>
            <ul class="edgetoedge" id="ulHome"></ul>
        </div>
        <div id="ePresentations">
            <div class="toolbar">
                <a class="button back" href="#">Back</a>
                <h1>AllaccessMD</h1>
            </div>
            <div id="ePresentationsData"><div class="progress"><font style="padding-right:5px;">Loading...</font><img border="0" src="Images/ajax-loader.gif" /></div>
            </div>
        </div>
        <div id="ePresentationDetails">
            <div class="toolbar">
                <a class="button back" href="#">Back</a>
                <h1>AllaccessMD</h1>
            </div>
            <div id="ePresentationDetailsData"><div class="progress"><font style="padding-right:5px;">Loading...</font><img border="0" src="Images/ajax-loader.gif" /></div>
            </div>
        </div>
    

    Javascript file:

    function setupHome(){
    if(localStorage.role == "Specialist"){
        var homeUL = '<li class="arrow"><a id="aEP" rel="s,' + localStorage.userID + '" href="#ePresentations">My E-Presentation</a></li>'
                + '<li class="arrow"><a id="aN" rel="s,' + localStorage.userID + '" href="#date">My Newsletter</a></li>'
                + '<li class="arrow"><a id="aE" rel="s,' + localStorage.userID + '" href="#date">My Events</a></li>'
                + '<li class="arrow"><a id="aMP" rel="s,' + localStorage.userID + '" href="#date">Medical Partners</a></li>'
                + '<li class="arrow"><a id="aS" rel="s,' + localStorage.userID + '" href="#date">Search</a></li>'
                + '<li class="arrow"><a id="aP" rel="s,' + localStorage.userID + '" href="#date">Profile</a></li>';
        $('#ulHome').html(homeUL);
    } else {
        var homeUL = '<li class="arrow"><a id="aMP" rel="m,' + localStorage.userID + '" href="#date">Medical Partners</a></li>'
                + '<li class="arrow"><a id="aS" rel="m,' + localStorage.userID + '" href="#date">Search</a></li>'
                + '<li class="arrow"><a id="aP" rel="m,' + localStorage.userID + '" href="#date">Profile</a></li>';
        $('#ulHome').html(homeUL);
    }
    $('#ePresentations').bind('pageAnimationStart', function (e){setupEPresentations(getID($('#aEP').attr('rel')).id);});
    }
    function setupEPresentations(sID){
    xmlhttp.onreadystatechange = function() {
        if (xmlhttp.readyState==4 && xmlhttp.status==200) {
            var epObject = JSON.parse(xmlhttp.responseText);
            var html = '<h1>Dr. ' + epObject.DR.DATA[0][1] + ' E-Presentation\'s</h1>';
            if(epObject.EP.DATA.length == 0){
                html += '<div><p>There are currently no E-Presentation\'s for this doctor.</p></div>';
            } else {
                html += '<ul class="edgetoedge">';
                for(var i in epObject.EP.DATA){
                    html += '<li class="arrow"><a id="' + epObject.EP.DATA[i][0] + '" href="#ePresentationDetails">' + epObject.EP.DATA[i][1] + '</a></li>';
                }
                html += '</ul>';
            }
            $('#ePresentationsData').html(html);
    
            $('#ePresentationsData li a').click(function(e)   {alert('what');setupEPresentationDetails(this.id);});
        }
    }
    xmlhttp.open("GET","Lib/ePresentations.cfm?Type=getAllEPsID&sID=" + sID,true);
    xmlhttp.send();
    }
    function setupEPresentationDetails(id){
    /*xmlhttp.onreadystatechange = function() {
        if (xmlhttp.readyState==4 && xmlhttp.status==200) {
            var epObject = JSON.parse(xmlhttp.responseText);
            var html = '<h1>Dr. ' + epObject.DATA[0][0] + ' E-Presentation</h1>';
            html += '<p>';
            //html += '<br />' + epObject.DATA[0][2].format("mmmm dd, yyyy");
            html += '<br /><strong>Rating:</strong> ' + Math.ceil(epObject.DATA[0][4]) + ' / 5 (' + epObject.DATA[0][5] + ' votes cast)';
            html += '<br /><br /><a rel="external" href="http://www.youtube.com/v/' + epObject.DATA[0][3] + '">Click here to view E-Presentation</a>';
            html += '</p>';
            $('#ePresentationDetailsData').html(html);
        }
    }
    xmlhttp.open("GET","Lib/ePresentations.cfm?Type=getEP&id=" + id,true);
    xmlhttp.send();*/
    $('#ePresentationDetailsData').html('I dont get called?');
     }
    

    What am I doing wrong? Maybe there is a better way to do this?

    Thanks!!

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

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

    发布评论

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

    评论(1

    谁许谁一生繁华 2024-09-24 19:18:55

    您使用什么版本的 JQT?
    您是否将整个应用程序包装在

    中?
    您是否使用 Safari 开发者模式查看过列表 HREF 在呈现时实际是什么?

    我会查看渲染的 HREF 中的以下内容:

    <li class="arrow"><a id="aS" rel="m,' + localStorage.userID + '" href="#date">Search</a></li>
    

    确保 html 是它应该的样子。 rel= 或你的引号没有被转义可能会导致它失败。但我没有看到任何明显的事情表明你做错了。

    您是否有可以发送给我的链接,以便我可以实际调试它?

    What version of JQT are you using?
    Are you wrapping your entire app in the <div id="jqt"></div> ?
    Have you looked at it using Safari developer mode to see what the list HREFs actually are when they are rendered?

    I would look at the rendered HREF for these:

    <li class="arrow"><a id="aS" rel="m,' + localStorage.userID + '" href="#date">Search</a></li>
    

    Make sure the html is what it should be. The rel= or your quotes not being escaped might be throwing it off. But I don't see anything obvious that you are doing wrong.

    Do you have a link you can send me so I can debug it in action?

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