Are there javascript callbacks I can hook into after submitting comments?
dave_stewart
New
I'd like to run the syntaxhighlighter.all() after comments are edited to convert pre tags to highlighted code.
Is there something I can hook into? I'd rather not go down the setTimeout (hack) route.
Thanks,
Dave
Is there something I can hook into? I'd rather not go down the setTimeout (hack) route.
Thanks,
Dave
0
Comments
http://vanillaforums.org/discussion/16067/is-there-a-way-to-make-discussion-marked-as-favorite-after-a-post
But I still consider it a bit hacky, as my solution was this:
$ButtonOptions = array('class' => 'Button CommentButton', 'onclick' =>"setTimeout(SyntaxHighlighter.update, 500)");
SyntaxHighlighter.update()is a wrapper function I added to SyntaxHighlighter with some jQuery initialization code to go through all page pre tags and get them ready for syntax highlighting.Is there a way in vanilla to add global hooks? I'd rather add the following to all pages, which is clientside so no need to extend multiple PHP files, and will attach itself to any new form elements created on clicks and so forth:
jQuery('#Form_Body').live('submit', SyntaxHighlighter.update);Cheers,Dave
Calling livequery() will most always work and you can ensure the js query is included in the page with:
$Sender->AddJsFile('jquery.livequery.js');jQuery('pre').livequery(SyntaxHighlighter.update);Any time I preview, or update a comment, the syntax highlighting is updated as soon as the pre is created.Thanks!
thisreference to tell you what item was just added so you can just call the highlighter on$(this).SyntaxHighlighter.highlight();does just the one pre.