Solved

Highlighting rows in jquery using bootsrap

Posted on 2014-10-07
1
81 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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)
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…

867 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

15 Experts available now in Live!

Get 1:1 Help Now