I have a view of teasers in Drupal. Each teaser has a click() handler which is supposed to send its node id as an argument to load a view via ajax. I've tried 2 different jquery approaches, but am having no luck.
The first example sends the nid for only the last node in the view. So that no matter what teaser I click only the nid for the last teaser gets sent.
Drupal.behaviors.ajaxview = function(context) {
$(".ajaxclick").click(function(){
$(".container").load(Drupal.settings.basePath + "myajax/" + <?php echo $node->nid;?>;);
});
}
In the second approach, a click on a button of class "ajaxview" will send the correct nid but but instead of sending for just the one clicked button to it's corresponding div, it will send a nid for EACH button with a class of "ajaxview" into EACH div with a class of "container". So I end up with the contents of every single view generated from every single teaser into every single div. WAAAAY too much!
$(document).ready(function() {
$(".ajaxclick").click(function(){
$(".container").load(Drupal.settings.basePath + "myajax/" + <?php echo $node->nid; ?>);
});
});
Here is the button;
<button class="ajaxclick">click</button>
And the div:
<div class="container"></div>
Any idea how I can get each click to send the nid of that teaser clicked upon as the argument and load only that view?