If I need to assign a click function dynamically, is there a way to ensure the click function is only assigned once and not duplicated?
this.click(function()
assuming that elements are being added to the html and you want to add an event only for elements added:
function addEvents2Elements()//prevent Duplicate
{
//this will add the event to all elements of class="ele2addevent"
$('.ele2addevent').not('.clickbind').on('click',function(){alert('once');})
//this will add a class an then the class="ele2addevent clickbind"
$('.ele2addevent').not('.clickbind').addClass('.clickbind');
//all elements of class="... clickbind" will not be catched anymore in the first line because of .not() every time you call this function
}
addEvents2Elements();
be shure that you add only with the class="ele2addevent", because after the bind it will be class="ele2addevent clickbind" and not catched again...