Solved

Highlighting rows in jquery using bootsrap

Posted on 2014-10-07
1
84 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

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

In this article you'll learn how to use Ajax calls within your CodeIgniter application. To explain this, I'll illustrate how to implement a simple contact form to allow visitors to send you an email through your web site.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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…

705 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