i want to pass a function as an parameter if an element was clicked.
But in the function that i pass i want to set an attribute information from the clicked element.
What is the best way to pass the attribute value to the inner of the function?
My JavaScript looks like this:
$('.edit-link').livequery(function(){
$('.edit-link').click(function(){
WMT.openOverlay($('#edit'),{
relativeTo: $('.search'),
width: $('.search'),
close: $('#cancel_edit'),
fillFields: function(){
return $.getJSON("ajax/edit.php?id=" + $(clickedElement).data('id'));
}
});
});
});
i want to send the data attribute “id” in the json.
You need to use
this. It pointed to clicked element:If this didn’t work try this: