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

  • Home
  • SEARCH
  • 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 8595157
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:22:10+00:00 2026-06-12T00:22:10+00:00

I have a listview like the following: <ul data-inset=true data-filter=true data-bind=foreach: growers data-role=listview id=ulGrowerList>

  • 0

I have a listview like the following:

               <ul data-inset="true" data-filter="true" data-bind="foreach: growers" data-role="listview" id="ulGrowerList">
          <li><a data-bind="click: $parent.setSelectedClassToGrowerList, attr: {id: growerId}"><span data-bind="text: growerName, attr: {id: growerId}, click: $parent.setSelectedClassToGrowerList" /></a></li>
      </ul>

My setSelectedClassToGrowerList looks like this:

    self.setSelectedClassToGrowerList = function (item, event) {

    $(ulGrowerList).closest('ul').find('a').removeClass('highlight');
    $(ulGrowerList).closest('ul').find('.selected').remove();

    $(event.target).toggleClass("highlight");
    if ($(event.target).hasClass("highlight")) {
      $(event.target).append("<span class='selected'>Selected</span>");
      //console.log(event.target.id);
      replaceByValue('GrowerID', event.target.id);
      postjson();

      //update GrowerInfo 
      $.getJSON("Grower/GetGrower", function (allData) {
        self.GrowerName(allData.Name);
        self.GrowerCompany(allData.CompanyName);
        self.GrowerAddress(allData.Address);
        self.ShowGrowerCompany(allData.ShowCompany);
        self.GrowerID(allData.ID);
      });

    } else {
      $(event.target).find(".selected").remove();
    }

As you see, I am binding setSelectedClassToGrowerList to both and tags because a click on the text (span) was not taking the required actions. Now, the problem is, when I click on the text itself, the “Selected” text is not displayed. The functionality I’m looking for is similar to this:
http://jsfiddle.net/czqXm/1/ except for ability to select multiple items which is already working.

The more I am working with knockout and jquery mobile, the more I am leaning towards the conclusion that they are not the best combination (sigh!).

  • 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-06-12T00:22:11+00:00Added an answer on June 12, 2026 at 12:22 am

    OK. I think this is a duplicate-handler problem.

    What’s happening is that when you click the text, because it has a separate click handler on the SPAN, inside the click-handler for the then in actual fact TWO click events are being registered……
    The first makes “Selected” appear, and the second makes it disappear again.

    I think you can probably simplify your binding to this

    <li><a data-bind="click: $parent.setSelectedClassToGrowerList, 
                      attr: {id: growerId}, 
                      text: growerName"></a></li>
    

    …But take a look at this fiddle

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

Sidebar

Related Questions

I have the following ListView with a custom list item: I would like to
I have a data in my ListView control like: Country State City India U.P.
I have a following problem. I have a ListView which returns data from SQL
I have an XML File resembling the following: <root> <parent label=parent1> <child label=child1> <element1>data</element1>
I have a ListView which has bound data, and two additional bindings like this:
I would like my screen to have a listview with a header. In my
I have a ListView where I would like to display things horizontally. That works
I have a ListView in my aspx file like this: <asp:ListView ID=ListView1 runat=server></asp:ListView> and
I have a ListView setup in details mode that looks like this: When the
I have a ListView control on my form set up like this in details

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.