ckeditor $ is not defined

ckeditor gem assumes that you load your JavaScripts at the top of your page instead of the bottom.

I used the SimpleForm integration by setting the textarea input field parameter to :as => :ckeditor which inserts the following code beneath your textarea:

//<![CDATA[
$(document).ready(function(){ if (CKEDITOR.instances['paper_abstract']) {CKEDITOR.remove(CKEDITOR.instances['unique_id_of_your_textarea_goes_here']);}CKEDITOR.replace('unique_id_of_your_textarea_goes_here', {"language":"en","rows":10,"toolbar":"Full","class":["ckeditor","required"],"required":true,"placeholder":"Please enter an abstract."}); });
//]]> 

However, if you load your JavaScript at the bottom of the page instead of the top, you’ll see this error in your Firebug Console: ‘$ is not defined’

My current solution was to not use the :as => :ckeditor parameter but instead call the above JavaScript code from within a js that gets loaded at the top of the page.

VN:F [1.9.22_1171]
Rating: 5.0/5 (1 vote cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)
ckeditor $ is not defined, 5.0 out of 5 based on 1 rating
Facebook Twitter Email

Leave a Reply