开发者

nicEdit behavior when being returned from jQuery AJAX request

I am using nicEdit to add rich text editing to a textarea. I am using the Codeigniter MVC framework and jQuery to make a simple AJAX call to create a new textarea then applying nicEdit to this new textarea once it's returned from the AJAX call. Everything works as expected and the nicEdit is instantiated as expected using the following code:

<html>

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script type="text/javascript" src="<? echo base_url();?>assets/js/nicEdit.js"></script>

<body>
<div id="area1"></div>
<input id="submit" type="submit" value="submit" />

<script>
$(document).ready(function() {

    $('#submit').click(function(){
        $.ajax
        ({
            type: "POST",
            url: "test/ajax",
            success: function(html)
            {
                $('#area1').html(html);
                new nicEditor().panelInstance('newArea');
            }
        });
    });
});
</script>

</body>
</html>

The test/ajax controller being called from the submit button click event is a function that returns a new textarea as follows:

    function ajax()
    {
        echo "<textarea id='newArea'></textarea>";
    }

In my main ap开发者_如何学JAVAplication, I am conceptually doing the same thing as described above, namely returning a new textarea from an AJAX call, then instantiating this new area on the AJAX success function. The problem I am having is that although nicEdit hooks onto this new textarea from the AJAX call, the nicEdit icons do not appear. The font format, font family and font size attributes are displayed and work, but none of the other icons (bold, italic, underline, etc.) are displayed.

Suggestions are appreciated.


I think you need to explicity specify where the icons file is located. You can do this passing a configuration dictionary when instantiating the nicEditor object: NicEdit Configuration Options

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜