Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6990957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:25:38+00:00 2026-05-27T19:25:38+00:00

I’m loading a list view full of items via getJSON. But when I tap

  • 0

I’m loading a list view full of items via getJSON.

But when I tap a list view item I want to arrive to the Details page for that item.

Now, in ASP.NET for example you would do Details.aspx?Id=1 but how will I do in jQuery Mobile? When I get the objects via my getJSON method. Do I need to store them in an array or something?

I should add that in my current getJSON response, none of the objects has an ID tied to it. But this is just a sandbox, I’m just playing around with jQuery Mobile and getting my feed from Flickr:

$(function() { 

     $.mobile.showPageLoadingMsg("Laddar...");

     $.getJSON("http://api.flickr.com/services/feeds/photos_public.gne?jsoncallback=?",
       {
         tags: "cat",
         tagmode: "any",
         format: "json"
       },

       function(data) {

         $.each(data.items, function(i,item){

             $('#list')
             .append('<li><a><img src="images/de.png" class="ui-li-icon">' + item.author + '</a></li>')
             .listview('refresh');

             });

         $.mobile.hidePageLoadingMsg();

       });

});

What is the praxis in setting up “Details pages” in jQuery Mobile? Should I create the in my code above with id=x and then in some way get a object at that index in my array (which I haven’t created yet)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T19:25:39+00:00Added an answer on May 27, 2026 at 7:25 pm

    First off there are some things you can do to greatly improve the performance of your code:

    $(function() { 
    
         var photos = {};
    
         $.mobile.showPageLoadingMsg("Laddar...");
    
         $.getJSON("http://api.flickr.com/services/feeds/photos_public.gne?jsoncallback=?",
           {
             tags: "cat",
             tagmode: "any",
             format: "json"
           },
    
           function(data) {
    
             //store photo data for later
             photos = data;
    
             //setup an array (or string) to buffer the output
             var output = [];
    
             for (var i = 0, len = data.items.length; i < len; i++) {
    
                 //add this index to the output array
                 output.push('<li><a data-index="' + i + '" href="#"><img src="images/de.png" class="ui-li-icon">' + data.items[i].author + '</a></li>');
    
             }
    
             //here I am selecting the list element only once and only refreshing it once
             $('#list').append(output.join('')).listview('refresh');
    
             $.mobile.hidePageLoadingMsg();
    
           });
    
    });
    

    Now you can add a click event handler to the links in the #list list-view and create the necessary pseudo-pages for jQuery Mobile:

    $('#list').delegate('a', 'click', function (event) {
    
        //get the index of this page/link and cache some objects
        var $this   = $(this),
            index   = $this.attr('data-index'),
            $toPage = $('#details_' + index);
    
        //stop the browser from scrolling to the top of the page due to the hash mark (#) in the link's href attribute
        event.preventDefault();
    
        //check to see if the page for the link clicked already exists, if so then don't re-add it to the DOM
        if ($toPage.length === 0) {
    
            //no page was found so create one, we can access the photos object to insert data related to the link clicked
            $('body').append('<div data-role="page" id="details_' + index + '"><div data-role="content"><p>Some Key: ' + photos.items[index].some_key + '</p><a data-role="button" href="#home">Back Home</a></div></div>');
    
            //set the $toPage variable to the newly added page so jQuery Mobile can navigate to it
            $toPage = $('#details_' + index);
        }
    
        //change to the desired page
        $.mobile.changePage($toPage);
    });
    

    Here is a demo: http://jsfiddle.net/m4Yt8/

    I’m not sure what your JSON looks like so I can’t say for sure how to add data from the JSON object into the new pages, however the above template should be pretty close.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to count how many characters a certain string has in PHP, but
I have a French site that I want to parse, but am running into
I want to construct a data frame in an Rcpp function, but when I
I used javascript for loading a picture on my website depending on which small
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
Basically, what I'm trying to create is a page of div tags, each has
I want use html5's new tag to play a wav file (currently only supported
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.