Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/83.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 单击listview中的项会导致两个URL请求_Jquery_Ruby On Rails_Jquery Mobile_Ruby On Rails 4 - Fatal编程技术网

Jquery 单击listview中的项会导致两个URL请求

Jquery 单击listview中的项会导致两个URL请求,jquery,ruby-on-rails,jquery-mobile,ruby-on-rails-4,Jquery,Ruby On Rails,Jquery Mobile,Ruby On Rails 4,我使用Jquery Mobile data role=listview循环浏览几个rails活动模型记录,并将它们显示在移动页面上。单击每个项目将导致一个URL非ajax调用。不幸的是,在点击一个项目时,请求会被发送两次 如何确保每次单击都调用一次URL 我应该补充一点,这不会发生在safari或chrome的桌面版本上。仅在我的移动设备mobile safari上 <div data-role="page" id="index"> <div data-

我使用Jquery Mobile data role=listview循环浏览几个rails活动模型记录,并将它们显示在移动页面上。单击每个项目将导致一个URL非ajax调用。不幸的是,在点击一个项目时,请求会被发送两次

如何确保每次单击都调用一次URL

我应该补充一点,这不会发生在safari或chrome的桌面版本上。仅在我的移动设备mobile safari上

<div data-role="page" id="index">
            <div data-theme="a" data-role="header">
                <h3>
                Header Text
               </h3>

        </div>

        <div data-role="content">

            <ul data-role="listview" data-split-icon="gear" data-split-theme="d" data-inset="true"  >

                <% @camps.each do |c| %>
                    <li>
                        <a href=<%= click_url(c.guid, @pubcode.guid, @qrclick.guid) %> rel="external">
                      <%= image_tag c.icon_url %>
                       <h2><%= c.title %></h2>
                        <p><%= c.description%></p>
                      </a>
                  </li>
                <%end%>


            </ul>

        </div>

<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.css">      
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.js"></script>
原始HTML输出:


你能在ROR操作后发布结果HTML吗?当然可以。看上面的变化,这似乎是移动Safari的一个问题;你能做这个测试吗:放置链接,并附加点击事件处理程序;请求是否仍被触发两次?
<div data-role="page" id="index">
        <div data-theme="a" data-role="header">
            <h3>
            Header Text

            </h3>

        </div>

        <div data-role="content">


        <ul data-role="listview" data-split-icon="gear" data-split-theme="d" data-inset="true"  >

                <li>
                    <a href=http://www.domain.me/click/73c637925cb577a81d5d48c9b67d973b/r4t3/0aa7cf0c15de32cfc7cea3af771a0b6a rel="external">
                  <img src="https://domain.com/image1.png" />
                   <h2>Title 1</h2>
                    <p> Some text here 1</p>
                  </a>
              </li>
                <li>
                    <a href=http://www.domain.me/click/d7ab954579d27bcfc4f9f31d8e93d924/r4t3/0aa7cf0c15de32cfc7cea3af771a0b6a rel="external">
                  <img src="https://domain.com/image2.png" />
                   <h2>Title 2</h2>
                    <p>Some text here 2</p>
                  </a>
              </li>
                <li>
                    <a href=http://www.domain.me/click/d7ab954579d27bcfc4f9f31d8e93d924/r4t3/0aa7cf0c15de32cfc7cea3af771a0b6a rel="external">
                  <img src="https://domain.com/image3.png"  />
                   <h2>Title 3</h2>
                    <p>Some text here 3</p>
                  </a>
              </li>


        </ul>

    </div>

<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.css">      
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.js"></script>