?
Solved

Highlighting rows in jquery using bootsrap

Posted on 2014-10-07
1
Medium Priority
?
85 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 2000 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

WordPress Tutorial 3: Plugins, Themes, and Widgets

The three most common changes you will make to your website involve the look (themes), the functionality (plugins), and modular elements (widgets).

In this article we will briefly define each again, and give you directions on how to install them.

Question has a verified solution.

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

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to dynamically set the form action using jQuery.
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…
Suggested Courses

777 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