如何使用javascript重绘具有更新信息的列表

时间:2014-02-20 11:01:45

标签: javascript jquery

我有html代码`

<body>
  <div data-role="page" id="home">
     <div data-role="header">
        <h1>site Details</h1>
     </div>
     <div data-role="content">
         <a href="#Site entry1" data-role="button" data-inline="true">Enter the details of site</a>
         <a href="#Modify site" data-role="button" data-inline="true">Modify site details</a>
     </div>
 </div>

 <div data-role="page" id="Site entry1">
     <div data-role="header">
        <a href="#home" data-rel="back" data-role="button" data-icon="home">Home</a>
        <h1>Welcome To enter the details of site</h1>
     </div>
     <div id="generalList"></div>
     <div data-role="content">
        <div class="content-primary">
        <form>
        <ul data-role="listview">
            <li data-role="fieldcontain">
                <label for="sitename">Site name:</label>
                <input type="text" sitename="name" id="siteName" value=""  />
            </li>
            <li data-role="fieldcontain">
                <label for="siteno">Site name:</label>
                <input type="text" siteno="siteno" id="siteNo" value=""  />
            </li>

            <a href="#Site entry2" data-role="button" data-inline="true">Next</a>
        </ul>
        </form>
        </div>
     </div>
 </div>

 <div data-role="page" id="Site entry2">

    <div data-role="content">
        <div class="content-primary">
        <form>
        <ul data-role="listview">
            <li data-role="fieldcontain">
                <label for="moduleNo">moduleNo:</label>
                <input type="text" moduleNo="moduleNo" id="moduleNo" value=""  />
            </li>
            <li class="ui-body ui-body-b">
                <fieldset class="ui-grid-a">
                        <div class="ui-block-b"><button type="submit" data-theme="a">Submit</button></div>
                    </fieldset>
            </li>

        </ul>

        </form>
        </div>
    </div>
    <div data-role="footer">
    <a href="#Site entry1"  data-role="button" data-icon="arrow-l">previous</a>
    <a href="#Site entry3" data-role="button" data-icon="arrow-r">Next</a>
    </div>
 </div>

 <div data-role="page" id="Site entry3">

    <div data-role="content">
        <div class="content-primary">
        <form>
        <ul data-role="listview">
            <li data-role="fieldcontain">
                <label for="executiveNo">executiveNo:</label>
                <input type="text" executiveNo="executiveNo" id="executiveNo" value=""  />
            </li>

            <li class="ui-body ui-body-b">
                <fieldset class="ui-grid-a">
                        <div class="ui-block-b"><button id="btn_3" type="submit" data-theme="a">Submit</button></div>
                    </fieldset>
            </li>

        </ul>

        </form>
        </div>
    </div>
    <div data-role="footer">
    <a href="#Site entry2" data-rel="back" data-role="button" data-icon="arrow-l">previous</a>
    <a href="#home"  data-role="button" data-icon="home">Home</a>
    </div>
 </div>

<div data-role="page" id="Modify site">
    <div data-role="header">
    <a href="home" data-rel="back" data-role="button" data-icon="home">Home</a>
    <h1>List of sites </h1>
    </div>
    <div data-role="content">
    <button id="btm_4" type="submit" data-theme="a">modify</button>
    </div>
    <div data-role="footer">
    </div>
</div>
</body>
</html>`

我已使用以下代码

创建了不同页面的字段列表
function makesite(site){
    var li = '<ul data-role="listview" >';
            $('body').find('[data-role="fieldcontain"]').each(function(key, value){         
                var title = $(this).find('label').html();  
                var val = $(this).find('[type="text"]').val();     
                li += '<li>'+title+' '+val+'</li>';
            });
            li +='</ul>';           
            $('#content').html(li).trigger('create');
             $('ul').listview('refresh');}

但问题是我需要在点击修改按钮的页面上显示添加了网站名称的网站列表,其中包含id&#34; modifysite&#34;。其中site,site name,site no,executive no,module no是全局变量。

我尝试过以下代码

Function redrawsites(site){
 var ul = makesite(site);

    $('#content').html(ul).trigger('create');
}

0 个答案:

没有答案