Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
0 votes
331 views
in Plugins by
edited by

I want to add a javascript to the element which contains the comment (question,answer) text from event module like this:

function process_event($event, $userid, $handle, $cookieid, $params) {

if($event == 'c_post'){

$this->output('<script>

//javascript code here:

 var Dom = document.getElementById("id of this element");

...

</script>')

}

}

But this doesn't work. What kind of plugin should be used for this purpose? I don't know how to get the id of the element in a layer module.

by
So you want to add and execute JavaScript returned in the HTML generated when posting a new comment?
by
@pupi1985 Yes exactly. Is it possible?
by
Yes, but the approach I'd use is to use DOM Observers. And I'm not sure there is any other way. https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver
by
Thank you pupi1985. I think I am going to change qa-global.js file.

Please log in or register to answer this question.

...