The idea of script below is “preview” the content from a text area. How it works?
$('#preview_post')is an anchor that trigger the preview mode.- The textarea content is readed as
var content = $('#post_content').val(); - The form where the textarea reside is hidden in order to show the div (#content_previewed) where the markup will be showen.
This is the JS code:
var pl_previwing = false;
$(document).ready(function(){
$('#preview_post').plPreviewPost();
});
jQuery.fn.plPreviewPost = function(options) {
this.on('click', function(){
var content = $('#post_content').val();
$('#replay_container form').toggle(function(){
pl_previwing = !pl_previwing;
});
console.log("previewing: " + pl_previwing);
//plCallParser();
});
};
function plCallParser(){
if (pl_previwing){
console.log("do a post here to process the markup");
}
}
What’s the problem here? If you note I have a commented line:
console.log("previewing: " + pl_previwing);
//plCallParser();
If I un-comment the line above, firebug will hang out abruptally and the browser freeze with the following message:

Translation:
A script of this page can be busy, or could has stopped responding.
You might stop the script, or wait for a response.
EDIT
- Current browser: 16.0.2, but it happens in all browsers
- The content of the textarea is not important, because it only have “test body”
At:
You need to put a “}; };” there, like so:
Just a simple error. I hate it when I mess up brackets.