deacs
deacs

Reputation: 4319

Unable to paste text into Redactor WYSIWYG editor. jQuery: $.parseHTML is not a function

Due to my lack of knowlegde when it comes to javascript and jquery, I can't solve this seemingly simple problem with Redactor.

Problem: I cannot paste any text into my redactor WYSIWYG editor (using ctrl v nor using the right mouse button).

When I try pasting text into the editor, my firebug console shows me the js error:

TypeError: $.parseHTML is not a function
    var $html = $('<div>').append($.parseHTML(html));

So I thought there must be something wrong with jquery, as jquery contains the $.parseHTML function. To be sure I checked that jquery and jquery.ui are imported and that I'm using the latest version, which all seems to be the case.

EDIT: This is the piece html out of my <head> where the js files are imported. Perhaps the order in which these are included is causing the problem?

<script src="/assets/8cf5dd34/jquery.js" type="text/javascript">
<script src="/assets/b52d4639/redactor.js" type="text/javascript">
<script src="/assets/b52d4639/lang/nl.js" type="text/javascript">
<script src="/assets/8cf5dd34/jui/js/jquery-ui.min.js" type="text/javascript">

Here is a example of the editor if you want to check it out.

BTW: I am using the Yii framework. The code to use the editor is as follows:

<?php echo $form->textArea($model,'text',array('class'=>'redactor' )); ?>

<?php 
    $this->widget('ImperaviRedactorWidget', array(
        // The textarea selector
        'selector' => '.redactor',
        // Some options, see http://imperavi.com/redactor/docs/
        'options' => array(
            'lang'=>'nl',
            'buttons'=>array('formatting', '|', 'bold', 'italic', 'deleted', '|', 'alignment', '|', 'unorderedlist', 'orderedlist', 'outdent', 'indent', '|', 'horizontalrule',  '|', 'table', 'link', 'image', '|', 'copy', 'paste'),
            'shortcuts'=>true,
        ),
    ));
?>

Anybody have any ideas? Any help is greatly appreciated.

Upvotes: 4

Views: 3007

Answers (2)

Daniel Adinugroho
Daniel Adinugroho

Reputation: 1399

I got the same error message because I use older version of framework. I change my framework to 1.1.14 and it works now!

Upvotes: 0

Rego Sen
Rego Sen

Reputation: 609

Redactor requires jQuery 1.8 or greater (I was using 1.7.2 and got the same error as you until I updated jQuery). You can query (ha!) your version by typing $.fn.jquery; at the browser's console.

If you're using rails, that means having 2.1 or greater of the jquery-rails gem. I now have this in my Gemfile:

gem 'jquery-rails', '2.1.4'

Omitting the version argument will result in jQuery 1.7.2 instead of latest (at least, that's what happened to me).

Upvotes: 7

Related Questions