Solved

Highlighting rows in jquery using bootsrap

Posted on 2014-10-07
1
79 Views
Last Modified: 2014-10-28
Hey guys... I have a table that has this scenario:

<tr class="warning c_APLM">
    <td style="vertical-align: middle;">5</td>
    <td style="vertical-align: middle;"><a href="#" onclick="onHold('APLM','20',this); return false;" class="t_APLM" data-hold="False" data-class="warning"><i class="icon-folder-open-alt"></i></a></td>
</tr>
<tr class=" c_APLM">
    <td style="vertical-align: middle;">6</td>
    <td style="vertical-align: middle;"><a href="#" onclick="onHold('APLM','20',this); return false;" class="t_APLM" data-hold="False" data-class=""><i class="icon-folder-open-alt"></i></a></td>
</tr>

Open in new window

These two rows share the same <tr> class (c_APLM). What they don't share is the highlight class (warning). For example: notice on the first <tr> it has a highlight of warning, while the other has no highlight. What i'm trying to do is if their current <a> data-hold=false, then since they are both part of the same tr class, make them both change their highlight to the info color which means the record is being held. Where i'm stuck is, let's say i wanna undo my hold and bring them back to the highlight they started with. I can't seem to pull this off. You'll notice that on the <a> i have a data-class. This is always going to be the original highlight. I can't seem to get it going. Here's what i got so far, and as always, all help is GREATLY appreciated!

function onHold(c,id,e){

  var h = $(e);

  // if it's onHold then make active (open folder)
  if(h.attr('data-hold')=='True'){

    // remove whatever the previous highlight was and revert back to original highlight
    $('.c_'+c).removeClass('warning danger info').addClass($('.c_'+c+' a').attr('data-class'));

    h.attr('data-hold','False');

  } else {
    //put on hold (close folder)

    // remove whatever the highlight is and make it the "info" highlight
    $('.c_'+c).removeClass('warning danger info').addClass('info');

    h.attr('data-hold','True');

  }
}

Open in new window

0
Comment
Question by:engineroom
1 Comment
 
LVL 22

Accepted Solution

by:
Mrunal earned 500 total points
ID: 40367785
Hi
Check this out.
I am not clear with your exact requirement but this will help you.

http://jsfiddle.net/954LmbzL/1/

Please share your comments on this.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction Chart.js, used properly, can visually add a difference to your charting applications. It engages your visitors and allows them to interact with data they otherwise wouldn't be able to without expensive and complicated systems. For this…
How to build a simple, quick and effective accordion menu using just 15 lines of jQuery and 2 css classes
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now