Drupal.behaviors.ajaxlinks = function (context) {
$('.morelink:not(.togg-processed)', context).addClass('togg-processed').each(function () {
$indexvar myindex = $('.morelink').index($(this));
var target = $('.newthing').eq($('.morelink').index($(this)))
var nid = $(".mynid").eq($indexmyindex).val();
$(this).click(function() {
if (($('.hiddenrows').eq($('.morelink').index($(this))myindex).is(":hidden"))
|| ($('.shownrows').eq($('.morelink').index($(this))myindex).is(":visible")))
{
$('.hiddenrows').eq($('.morelink').index($(this))myindex).show();
$('.newthing').eq($('.morelink').index($(this))myindex).show();
var toLoad = Drupal.settings.basePath + 'replies/' + nid;
xhr = $.ajax({
url: toLoad,
success: function(data) {
$(target).css( "height","200px" );
$(target).html($(data));
Drupal.attachBehaviors(context);
}
});
}
else
{
$('.hiddenrows').eq($('.morelink').index($(this))myindex).hide();
$('.newthing').eq($('.morelink').index($(this))myindex).hide();
}
return false;
});
});
};
And here is the php which shows in the content-type.tpl.php for both views:
<div class="newthing" >
<input type="hidden" class="mynid" value=<?php echo $node->nid;?> />
</div> <!-- newthing -->