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 3437286
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T08:02:47+00:00 2026-05-18T08:02:47+00:00

Im using jQTouch to make a mobile version of my website, and i need

  • 0

Im using jQTouch to make a mobile version of my website, and i need some help.

Im using html5 storage feature. I have a list of jobs and I want to click on one job, and shows that job information in another div.

This is my code:

var uid;
var job_name;

for (var i=0; i<results.rows.length; i++) {    
var row = results.rows.item(i);

uid  = row['id'];
job_name   = row['job_name'];

$("ul#my_jobs").append('<li class="arrow" id="job_' + uid +'"><a class="fade" href="#prueba">' + job_name + '</a></li>');


$("li#job_" + row['id']).bind('tap', function(){
    $("#job_detail").html(row['id']);
});
}

The jobs are listing ok, but when I tap on one of them, always shows the last job.

Thanks!

  • 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-18T08:02:48+00:00Added an answer on May 18, 2026 at 8:02 am

    It should look like this (without changing your layout too much):

    var uid, job_name;
    for (var i=0; i<results.rows.length; i++) {    
      var row = results.rows.item(i);
      uid  = row['id'];
      job_name   = row['job_name'];
    
      $("ul#my_jobs").append('<li class="arrow" id="job_' + uid +'"><a class="fade" href="#prueba">' + job_name + '</a></li>');
      (function(id) {
        $("li#job_" + id).bind('tap', function(){
          $("#job_detail").html(id);
        });
      })(uid)
    }
    

    JavaScript doesn’t have block scope here, so that row variable, even though it’s inside the for loop, is scope to the entire function, and it gets replaced each iteration…and ends up being the last value (which is why you see the last id each time).

    A slimmed down version taking advantage of this new scope would be:

    for (var i=0; i<results.rows.length; i++) {    
      var row = results.rows.item(i);
      (function(uid, job_name) {
        $('<li class="arrow" id="job_' + uid +'"><a class="fade" href="#prueba">' + job_name + '</a></li>').bind('tap', function(){
          $("#job_detail").html(uid);
        }).appendTo("#my_jobs");
      })(row['id'], row['job_name']);
    }
    

    This declares those other uid and jod_name variables only where they’re needed, and eliminated the extra traversal inside the loop (finding the <li> you just created).

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

Sidebar

Related Questions

I am trying to make an Iphone application for mobile health using html5,javascript, jqtouch
I am using jqtouch to make a mobile website. I am also implementing a
I am working on an iPhone mobile web app using jqtouch to make it
I have a rails app with a mobile view using jqtouch. If the application
I have a website designed for the android browser using jquery/jqtouch. As a part
i've got some problems using jQTouch. I have this Link <a href=#site_map class=swap>Map</a> and
I'm writing an HTML5 app with jQTouch for mobile browsers. I'm setting variables using
I'm having a problem with onSubmit. I'm building a little mobile website using jQTouch
I'm using jQtouch for a small mobile app. Using the default CSS the app
Using online interfaces to a version control system is a nice way to have

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.