Le_Coeur
Le_Coeur

Reputation: 1541

Multiple click events

I have some popup dialogs on my webpage, in each of these dialogs I have defined some click event with jQuery :

 $(".links_view").click(function(e){     //code     });

But the problem is when I activate one this click event, it will be executed in each dialog...

Upvotes: 1

Views: 481

Answers (2)

Jared Forsyth
Jared Forsyth

Reputation: 13172

I believe you want to isolate your click attachment; to do this, just make your selector (currently ".links_view") more specific.

For example, if you have the following HTML

<div id="one">
  <button class="links_view">Hi</button>
</div>
<div id="two">
  <button class="links_view">Ho</button>
</div>

the code $('.links_view') will grab both, but you can use $('#one .links_view') to just get the first or $('#two .links_view') for the second.

Here's a good tutorial on selectors: http://reference.sitepoint.com/css/selectorref

Upvotes: 0

Luca Filosofi
Luca Filosofi

Reputation: 31173

$(".links_view").click(function(e){  e.preventDefault()   });

also have your dialogs different class OR id!?

Upvotes: 2

Related Questions