I have this [and more] very inefficient bit of click event binding code in my project and would like to find a way to make this faster, as I believe it is the cause of a lot of slowdown of my frontend. Would appreciate any tips on how to make this smoother so that it scales when there are more clickable events on the page.
Each of these events are bound to individual items when loaded and I know there must be a better more efficient way to bind the click events to the each of the elements within each item.
Thanks for any help.
$(self.colBodySelection + " #post_dm_" + sItemId).unbind();
$(self.colBodySelection + " #post_dm_" + sItemId).click(function(){
var sResponseType = $(this).attr("response_type");
self.fnRespond(sItemId, sResponseType);
});
$(self.colBodySelection + " #post_body_" + sItemId).unbind();
$(self.colBodySelection + " #post_body_" + sItemId).click(function(){
//self.fnPostSelect();
});
$(self.colBodySelection + " #select_" + sItemId).unbind();
$(self.colBodySelection + " #select_" + sItemId).click(function(){
self.fnPostSelect(1, sItemId);
});
$(self.colBodySelection + " #poster_" + sItemId).unbind();
$(self.colBodySelection + " #poster_" + sItemId).click(function(){
self.fnLoadUserColumn();
$(self.colBodySelection + " #settings_box_" + sItemId).slideUp("fast");
$(self.colBodySelection + " #history_" + sItemId).slideUp("fast");
$(self.colBodySelection + " #respond_"+sItemId).slideUp("fast");
$(self.colBodySelection + " #assign_box_" + sItemId).slideUp("fast");
});