FBJS...OnClick not being passed. DHTML/setInnerXHtml problem
thanks so much in advance...here is the problem...
I am trying to add dynamic HTML element (EX. [delete]),everytime on a event call using FBJS.I am able to append the element using following code.
var oldFriendHtml = document.getElementById('friend_container'); var numi = document.getElementById('theValue'); var num = (document.getElementById("theValue").getValue()-1)+2; numi.value = num; var newElementId = "new"+num; var newFriendHTML = document.createElement('div'); newFriendHTML.setId(newElementId); newFriendHTML.setInnerXTML("HTML TO BE ADDED"); oldFriendHtml.开发者_运维问答appendChild(newFriendHTML);
The problem I am facing is that FBJS parses out the onClick part (event call ) out from the original HTML added .This stops me in the further activity on the added element .It also removes the styling added in the HTML ..
Regarding onclick being parsed out of setInnerXHTML, you can add the event later by using addEventListener.
Here is some sample:
var my_obj = document.getElementById('test');
// add a new event listener for each type of event you needed to capture
my_obj.addEventListener('click',my_click_func); // in your case is onclick
function my_click_func(evnt){
// some action
}
more details see http://developers.facebook.com/docs/fbjs#events
精彩评论