Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing ID Attributes

Tags:

jquery

scope

I am grabbing divs using the .each function, but I am having trouble passing the ID I get to my modal box function. Here is the code:

(function() {
$('div.heriyah').each(function() { 
$(this).html('<div class="add"><div id="add_button_container"><div id="add_button" class="edit_links">+ ADD NEW CONTENT</div></div></div><div class="clear"></div><div class="placeable"></div></div>');

$('.add').click(function() {
$.fallr('show', {
          content     :  '<iframe width="620" height="600" src="<? echo $URL ?>/manage_content.php?id=<? echo $pageID; ?>&div='+$(this).attr('id')+'"></iframe>',
          width       : 620 + 5, // 100 = for width padding
          height         : 600,
          closeKey        : true,
          closeOverlay    : true,
          buttons     : {}
}); 
}); 

}); 

})();

I get Undefined if I request the variable inside my modal box.

I use this:

'+$(this).attr('id')+'

To grab the id inside my modal box function.

Thanks, Drummer

like image 460
drummer392 Avatar asked Sep 29 '26 00:09

drummer392


1 Answers

I'm not sure what fallr is but try changing your code to this:

    (function() {
    $('div.heriyah').each(function() { 
    $(this).html('<div class="add"><div id="add_button_container"><div id="add_button" class="edit_links">+ ADD NEW CONTENT</div></div></div><div class="clear"></div><div class="placeable"></div></div>'); 

    var curID = $(this).attr('id');//get the id before you go into fallr

    $('.add').click(function() {
    $.fallr('show', {
              content     :  '<iframe width="620" height="600" src="<? echo $URL ?>/manage_content.php?id=<? echo $pageID; ?>&div='+curID +'"></iframe>',
              width       : 620 + 5, // 100 = for width padding
              height         : 600,
              closeKey        : true,
              closeOverlay    : true,
              buttons     : {}
    }); 
    }); 

    }); 
})();
like image 98
Abe Miessler Avatar answered Sep 30 '26 15:09

Abe Miessler