Allow for Mutliple ID's and Classes when using more than one instance.

May 7, 2013 at 10:14 PM
Maybe this will help someone. I needed two instances, and wanted to give 2 ID's and a class. This is not hard and maybe it was posted somewhere but I thought I would post it anyways:

Added this:
if (opts.idName) iframe.attr("id",opts.idName);
if (opts.className) iframe.attr("class",opts.className);
after this about line 45:
var iframe = this.iframe = $("<iframe/>").height(textarea.height());
Then added the options on the page:
$("#answer").htmlarea({
    // Override/Specify the Toolbar buttons to show
    toolbar: [
        ["html"],
        ["bold", "italic", "underline"],
        ["orderedList", "unorderedList"],
        ["justifyleft", "justifycenter", "justifyright"],
        ["forecolor", "image"]                                      
    ],
    idName:"editor1",
    className:"c_editor"                  
});
        
$("#question").htmlarea({
    // Override/Specify the Toolbar buttons to show
    toolbar: [
        ["html"],
        ["bold", "italic", "underline"],
        ["orderedList", "unorderedList"],
        ["justifyleft", "justifycenter", "justifyright"],
        ["forecolor"]                                      
    ],
    idName:"editor2",
    className:"c_editor"               
});

$(".c_editor").contents().find('body').css({"font-family" : "Verdana, Geneva, sans-serif" });   
$(".c_editor").css({"border-color": "#000", 
                        "border-width":"1px", 
                            "border-style":"solid"});