8000 Load text into CLEditor via ajax call · Issue #18 · cleditor/cleditor · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Load text into CLEditor via ajax call #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Nicero opened this issue Feb 5, 2012 · 1 comment
Open

Load text into CLEditor via ajax call #18

Nicero opened this issue Feb 5, 2012 · 1 comment

Comments

@Nicero
Copy link
Nicero commented Feb 5, 2012

I would like to load some text retrieved from a dB into a CLEditor driven textarea.

The user clicks a link:

<a class="editlink" id="<?php echo $review['id']; ?>" href="#"><?php echo $review['title']; ?></a>

JQuery passes the ID to GO.PHP:

$(".editlink").click(function() {
    $.get("go.php", {param: $(this).attr('id')},
        function(data) {
            $(#area1').html(data);
        });
    return false;
});

GO.PHP retrieves the text from the dB:

$qry = mysql_query("SELECT * FROM reviews WHERE id = ".$_GET['param']." ");
while($review = mysql_fetch_array($qry)) {
    echo $review['description'];
}

and the HTML:

<textarea id="area1" rows="30" cols="55"></textarea>

As confirmed by Firebug consolle, ID and the text are retrieved correctly. The problem I noticed is that when CLEditor is active, loaded and working I need to refresh the page to see the text loaded into the textarea. If CLEditor is not loaded, the text is loaded via ajax suddently without any page refresh.

I did read about :

editor.$area.val(htmltext);
editor.updateFrame();

but as I'm still learning jQuery would someone be so kind to add these two lines into my above code?

@funivan
Copy link
funivan commented May 28, 2012

Try this code

$(".editlink").click(function() {
    $.get("go.php", {param: $(this).attr('id')},
        function(data) {
            var editor = $('#area1').cleditor();
            editor.$area.val(data);
            editor.updateFrame();
        });
    return false;
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
0