在Jquery Mobile中读取URL参数

时间:2013-03-05 04:35:18

标签: javascript jquery jquery-mobile mobile get

带有列表视图的我的Jquery移动表格具有以下格式。

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

  <div data-role="header" data-theme="b">
        <h1>Area</h1>
        <a href="../MenuePages/Dictionaries.aspx" class='ui-btn-left ui-btn-back' data-icon='arrow-l' rel="external">Back</a>   <!-- your button to go back to index.php#user page -->
   <a href="AddArea.aspx" data-role="button" data-icon="plus" data-theme="d" style="float:left;"  rel="external" data-transition="slide">Add</a>
    </div><!-- /header -->

    <div data-role="content">  
    <ul data-role="listview" data-inset="true" data-theme="c"  data-filter="true" id="areaList" data-split-icon="gear" data-split-theme="d">
  <li><a href="#dialog?AreaNo=1" data-rel="dialog" data-transition="pop">Test</a><a class="deleteMe"></a></li>
    </ul>

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

     <div data-role="footer" data-theme="b" data-position="fixed">

            <div data-role="navbar">
            <ul>

               <li><a href="" data-role="tab" data-icon="arrow-u" class="returnTopAction">Top</a></li>
            </ul>
        </div>
    </div>


        <!-- /content -->

</div><!-- /page -->
<div data-role="page" id="dialog">
  <div data-role="header" data-theme="b">
    <h1>Options</h1>
  </div>   

 <ul data-role="listview" data-inset="false"
                data-theme="c">
               <%-- <li data-role="divider" data-theme="a">Options</li>--%>
                <li data-icon="false"><a>Edit</a></li>
                <li data-icon="false"><a>Delete</a></li>
                <li data-icon="false"><a>...</a></li>
            </ul>   
</div> 

我需要打开“对话框”div作为listview行上的对话框单击和 从对话框中读取url参数。我需要获得AreaNo 来自url

  • 标记的参数,并将其传递给打开的编辑网址 对话。目前我无法打开对话框,但它无法正常工作。 请帮助和抱歉英语不好

  • 1 个答案:

    答案 0 :(得分:1)

    我将html更改为

    <div data-role="page" id="arealistpage">
        <div data-role="header" data-theme="b">
             <h1>Area</h1>
     <a href="../MenuePages/Dictionaries.aspx" class='ui-btn-left ui-btn-back'
            data-icon='arrow-l' rel="external">Back</a> 
            <!-- your button to go back
            to index.php#user page --> <a href="AddArea.aspx" data-role="button" data-icon="plus" data-theme="d"
            style="float:left;" rel="external" data-transition="slide">Add</a>
    
        </div>
        <!-- /header -->
        <div data-role="content">
            <div id="primaryList">
                <ul data-role="listview" data-inset="true" data-theme="c" data-filter="true"
                id="areaList" data-split-icon="gear" data-split-theme="d" id='dialogListView'>
                    <li><a href="#dialog" data-rel="dialog" data-transition="pop" data-areano="1">Test</a>
    
                        <a
                        class="deleteMe"></a>
                    </li>
                </ul>
            </div>
        </div>
        <!-- /content -->
        <div data-role="footer" data-theme="b" data-position="fixed">
            <div data-role="navbar">
                <ul>
                    <li><a href="" data-role="tab" data-icon="arrow-u" class="returnTopAction">Top</a>
    
                    </li>
                </ul>
            </div>
        </div>
        <!-- /content -->
    </div>
    <!-- Dialog Page -->
    <div data-role="page" id="dialog">
        <div data-role="header" data-theme="b">
             <h1>Options</h1>
    
        </div>
        <div data-role="content">
            <ul data-role="listview" data-inset="false" data-theme="c">
                <!-- <li data-role="divider" data-theme="a">Options</li>-->
                <li data-icon="false"><a>Edit</a>
    
                </li>
                <li data-icon="false"><a>Delete</a>
    
                </li>
                <li data-icon="false"><a>...</a>
    
                </li>
            </ul>
        </div>
    </div>
    

    并为列表添加了点击事件,如下所示

    $('div[id="primaryList"] ul[data-role="listview"] a').live("click", function () {
        var areaNo = $(this).data("areano");
        sessionStorage.areaNo = areaNo;
        alert("area no : " + sessionStorage.areaNo);
    });
    

    现在,您可以使用会话存储变量sessionStorage.areaNo访问整个应用程序中的区号。详细了解sessionStorage here

    这是一个工作小提琴http://jsfiddle.net/9CctZ/7/