0 Replies Latest reply on Dec 5, 2012 6:36 AM by Ryan Wade

    Refreshing a page and losing button functionality

      Hi I was wondering if anyone could help with an issue I'm having.

       

      I currently have a list of items. There are up to 150 total, but I am only displaying 20 at a time. Currently I have a button at the bottom of the page that, when clicked, refreshes the page with the next 20 items in the list. The problem is that I can only click that button once and then it's functionality is gone.

       

      Here is the code for the actual page:

       

      <% $jstring["response"]["docs"][$start...$end].each do |doc| %>

            <% if doc["document_title"] != nil && doc["filename"] != nil %>

             <% if doc["document_date"] != nil %>

                <% if Time.parse(doc["document_date"]).strftime("%F") >= $chooseFirst.strftime("%F") && Time.parse(doc["document_date"]).strftime("%F") <= $chooseLast.strftime("%F") %>

                <li style="-webkit-transform: translateZ(0); position: relative;"><a href="<%= url_for :action => :display, :query => {:pdf => doc["filename"] } %>"><%=  Time.parse(doc["document_date"]).strftime("%Y-%m") %>: <span style="white-space: pre-line;"> <%= doc["document_title"][0] %> </span> </a></li>

               <% end %>

             <% else %>

              <li style="-webkit-transform: translateZ(0); position: relative;"><a href="<%= url_for :action => :display, :query => {:pdf => doc["filename"] } %>">

                <span style="white-space: pre-line;"> <%= doc["document_title"][0] %> </span> </a></li>

             <% end %>

             <% end %>

            <% end %>

          </ul>

        </div>

        <div data-role="footer" data-position="inline">

          <% if $start != 0 %>

          <a href="<%= url_for :action => :previous %>" class="ui-btn-left" >Previous</a>

          <% end %>

          <% if $end != $jstring["response"]["docs"].length %>

          <a href="<%= url_for :action => :next %>" style="float: right; margin-right: 2px;" >Next</a>

          <% end %>

        </div>

       

      And here is the Ruby code:

       

      def next
          $start = $start + 20
          $end = $end + 20
          if $end > $jstring["response"]["docs"].length
            $end = $jstring["response"]["docs"].length
          end
          redirect :action => :index
      end
      

       

      I've found that I can use a WebView.refresh() after the redirect and the buttons will function, but every time I click a button a "Error Loading Page" dialog pops up for a split second before the new page loads. Can anyone help with some ideas for fixing this?

       

      Thanks,

      Ryan