1

Topic: tiny_mce.js on demand

Hi, i want to load tiny_mce.js only when i need edit some message (edit button onclick)... but all fail...

I try this (very simplified....):

function includeJS(source) {
    var e = document.createElement('script');
    e.setAttribute('type', 'text/javascript');
    e.text = source;
    document.getElementsByTagName('HEAD')[0].appendChild(e);
}

function require(url) {
    var cnx = (window.ActiveXObject) ? new ActiveXObject("MsXml2.XmlHttp") : new XMLHttpRequest();
    if( cnx ) {
        cnx.open("GET", url, false);
        cnx.send(null);
            includeJS(cnx.responseText);
        }
    } else {
        alert("ERROR");
    }
}

function edit() {
    --- blablabla ---
    require('/tinymce/tiny_mce.js');
    tinyMCE.init({.........});
    --- blablabla ---
}

<input type="button" value="Edit" onclick="edit()" />

But don't work.... i modify tiny_mce.js to 'hack' t.baseURL on _init method and load scripts to my own functions (document.write is a problem - blank document)... plugins are included but nothing happend... no errors.

Then, i change my load script to this (very simplified too):

function require(url) {
    var e = document.createElement('script');
    e.setAttribute('type', 'text/javascript');
    e.src = url;
    document.getElementsByTagName('HEAD')[0].appendChild(e);
    --- WAIT for load script ----
}

and same problem sad

some idea?

Thanks in advance smile

--- Sorry, i am spanish... my english is too bad smile

Last edited by Tito (2008-10-07 12:44:57)

2

Re: tiny_mce.js on demand

Use the official way: http://tinymce.moxiecode.com/examples/example_13.php

Best regards,
Spocke - Main developer of TinyMCE

3

Re: tiny_mce.js on demand

I know, i know.... but I want use tinymce on boards (fast reply, fast edit ... normal reply, edit, etc is implemented), load it when i need only (require tiny_mce.js on the fly because it's very heavy and i don't need it all times)

I tried another thing... Load tiny_mce.js into iframe (created on the fly) but I can't use a textarea from iframe's parent, something like that:

tinymce = window.frames['onTheFlyIframe'].tinymce;
tinyMCE = window.frames['onTheFlyIframe'].tinyMCE;

tinyMCE.init({
    mode : "exact",
    elements : document.getElementById('textarea')
});

elements only accept string... why not an object (or array of objects) to work too? ... communication will be perfect, tiny working relative to that objects (same, parent and child documents) wink

It's an idea ... still working on how to do what I need wink

Last edited by Tito (2008-10-08 10:34:33)

4

Re: tiny_mce.js on demand

Ok, "load on demand using compressor" use a diferent JS smile

tiny_mce_gzip.js -> 3 Kb

Thanks for all wink

5

Re: tiny_mce.js on demand

a solution to this problem: http://blog.sponagl.de/2008/12/16/tinym … -on-demand
best
paul

Last edited by trigan (2008-12-18 15:56:21)