Nothing to see...

A simple blog about all things in the world that is ridikulouse.

Technological steps, are man kinds greatest achievements

Not a Fighter, but a lover of Tech.

Love of the internet

The Internet is the final frontier for open connected networks, it promotes speech and advances knowledge for any mere person. The internet is fast becoming a need rather a want, and it is recognised by the UN as a necessity for the modern person.

Photography

Photography is more than just Art and expression, it is the manipulation of the light and provokes emotion and memories.

Have a look around

The articles on this blog represent my thoughts and views at the time of writing, I can always change my views through further education...please don't hold me against my views. Some of the articles have been written to assist anyone else with similar issues - it also helps me to remember. Hope you get something out of this.

Thursday, April 14, 2011

Jquery IPWEDITOR, tinyMCE, and Live

Hi,
I thought that I would share this with you: I wanted to add DOM elements and have the IPWEDITOR with tinyMCE fire everytime I clicked the element to launch tinyMCE. I found out how to do it when elements are in the dom and then have the jquery code fire-up, however, I couldn't get it to fire when I'm dynamically loading elements into the dom.

So here's what I did, I used the live function in jquery:

Normally:
//Create an instance of the TinyMCE    var ed = new tinymce.Editor(".f_editableArea", {                    some_setting: 1                });
//Apply this to a selection$(".f_editableArea").editable({                    type: "wysiwyg",                    editor: ed,                    onSubmit: function submitData(content){                        alert(content.current)                    },                    submit: 'ok',                    cancel:'cancel'                });




Now, to use the live function you would do it this way :


    var ed = new tinymce.Editor(".f_editableArea", {
                    some_setting: 1
                });
 $(".f_editableArea").live("click", function(){                    $(this).editable({
                    type: "wysiwyg",
                    editor: ed,
                    onSubmit: function submitData(content){
                        alert(content.current)
                    },
                    submit: 'ok',
                    cancel:'cancel'
                });
 });

The highlighted section is the new section, I simply called the live function on the selection passing in the event as click and using a function. I then used this to call the selection and launch the plugin.

I hope this helps...