Alanaktion / lwrte

Automatically exported from code.google.com/p/lwrte
0 stars 0 forks source link

Using get_content #5

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
This looks an excellent plugin. I am not a jQuery pro so was looking for 
the syntax on how to call get_content() from my code. An example would be 
highly appreciated.

For example, I tried $('.rte').get_content() within your demo which isn't 
right!!

Original issue reported on code.google.com by yusufnb on 29 Jan 2009 at 4:22

GoogleCodeExporter commented 8 years ago
Hmmm....it's not suit for external usage rightnow :( Only inside of controls. 
Will
try to add this in next release.

Original comment by plandem on 31 Jan 2009 at 10:14

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
it is possible to slightly modify the code to make it return editor object on 
creation:

extension function inside jquery.rte.js (replace with following):

jQuery.fn.rte = function(options)
{
    editors = new Array();
    $(this).each( function() {
        editors.push(new lwRTE (this, options));
    });

    return editors;
}

the you will be able to use smth like:

    eds = $('.rte').rte({
        css: 'default.css',
        width: '99%',
        height: 200,
        controls_rte: rte_toolbar
    });

    eds[0].set_content('test content from outside');

in your code (eds wil be an arry of editor objects, that were created).

Original comment by Psychode...@gmail.com on 1 Feb 2009 at 9:35

GoogleCodeExporter commented 8 years ago
Perhaps is better to declare a global object of editors ... currently created, 
and ad them by ID..

if(!rte) var rte = {};
rte.instances = []

jQuery.fn.rte = function(options)
{
    $(this).each( function() {
        rte.instances[this.id] = new lwRTE (this, options);
    });

    return editors;
}

With this form, you can gain access from everywhere.
Or if you want, you can't add them by textarea name....

Original comment by jor...@gmail.com on 2 Feb 2009 at 4:30

GoogleCodeExporter commented 8 years ago
don't like global scope alot. first variant will be implemented :)

Original comment by plandem on 6 Feb 2009 at 4:00

GoogleCodeExporter commented 8 years ago
It's also may come handy not to create array for objects each time we convert 
anything to editor, but add it to the previous, to collect. And to implement 
method 
to get those from rte object.

Original comment by Psychode...@gmail.com on 6 Feb 2009 at 4:57

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
next issue will be used. in that case you will be able to collect rte.

for example:

var arr = $('.rte1').rte();
$('.rte2').rte({}, arr);

rte's without ID will be accessed via arr[0....N], but rte's with ID will be 
accessed
via arr['ID']

---
jQuery.fn.rte = function(options, editors) {
    if(!editors || editors.constructor != Array) {
        editors = new Array();
    }

    $(this).each( function(i) {
        var id = (this.id) ? this.id : editors.length;
        editors[id] = new lwRTE (this, options || {});
    });

    return editors;
}

    return editors;

Original comment by plandem on 5 Mar 2009 at 8:20