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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:03:50+00:00 2026-06-17T10:03:50+00:00

I am doing knockout binding for inserting values into the table. If there is

  • 0

I am doing knockout binding for inserting values into the table.
If there is nuber of rows in table is 0, then I have to show an alert message.
But for that I need to count the number of rows showing data.

my view’s code is as Below:

    <table class="table table-hover table-bordered datagrid" style="width: 355px;" id="remodellingTable">
       <thead>
         <tr>
            <th>First Name</th>
            <th>Last Name</th>
            <th>Address</th>
            <th>City</th>
            <th>State</th>
         </tr>
       </thead>
       <tbody data-bind="foreach:items">
          <tr>
             <td data-bind="text:fname" id="tdfname"></td>
             <td data-bind="text:lname"></td>
             <td data-bind="text:addr"></td>
             <td data-bind="text:city"></td>
             <td data-bind="text:state"></td>
          </tr>
       </tbody>
    </table>
<button type="button" class="btn" id="nexttarget"> Next <i class="icon-arrow-right"></i></button>

and my jquery code for this checking is as below:

$('#nexttarget').live('click', function () 
{
     var rowcount = ('#remodellingTable > tbody > tr').length;
    if (rowcount > 0) 
    {
       $('#authorize').hide();
       $('#target').hide();
       $('#sideone').show();
    }
    else 
    {
       alert("There are no targets selected");
    }

}
  • 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-17T10:03:51+00:00Added an answer on June 17, 2026 at 10:03 am

    You forgot to invoke jQuery, using $:

    var rowcount = $('#remodellingTable > tbody > tr').length;
    

    http://jsfiddle.net/ENQrX/

    If you don’t invoke jQuery, you’re simply evaluating the length of the string '#remodellingTable > tbody > tr', which is obviously irrelevant.

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

Sidebar

Related Questions

What I am currently doing when binding same element to multiple actions in knockout
Can someone show me how to create a table in knockout for an observableArray
I've been doing a lot of research into frameworks like backbone and knockout, and
I'm just getting started with knockout.js. I have a foreach binding like this, which
Doing my first SL4 MVVM RIA based application and i ran into the following
Doing some jquery animation. I have certain divs set up with an attribute of
Doing a mysqli query and COUNTing the results, is there a preferred comparison operator
Doing code analysis of the project and get the message Reference-counted object is used
I started to play around with knockout.js and in doing so I used the
Doing a search using django-sphinx gives me results._sphinx that says there were 68 results,

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.