{"id":1759,"date":"2022-08-30T15:19:12","date_gmt":"2022-08-30T15:19:12","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/12\/01\/angularjs-with-ckeditor-is-producing-an-arcane-error-on-load-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:19:12","modified_gmt":"2022-08-30T15:19:12","slug":"angularjs-with-ckeditor-is-producing-an-arcane-error-on-load-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/angularjs-with-ckeditor-is-producing-an-arcane-error-on-load-collection-of-common-programming-errors\/","title":{"rendered":"AngularJS with ckeditor is producing an arcane error on load-Collection of common programming errors"},"content":{"rendered":"<p>Using the solution from this problem: Bind Ckeditor value to model text in angularjs and rails<\/p>\n<p>I get the following error whenever I try to use the directive on my page.<\/p>\n<pre><code>Uncaught TypeError: Cannot call method 'unselectable' of null ckeditor.js:290\na ckeditor.js:290\n(anonymous function) ckeditor.js:286\ni ckeditor.js:10\nCKEDITOR.event.CKEDITOR.event.fire ckeditor.js:12\nCKEDITOR.editor.CKEDITOR.editor.fire ckeditor.js:13\nCKEDITOR.event.CKEDITOR.event.fireOnce ckeditor.js:12\nCKEDITOR.editor.CKEDITOR.editor.fireOnce ckeditor.js:13\n(anonymous function) ckeditor.js:222\nn ckeditor.js:202\nCKEDITOR.scriptLoader.load ckeditor.js:202\n(anonymous function) ckeditor.js:221\n(anonymous function) ckeditor.js:209\n(anonymous function) ckeditor.js:207\nn ckeditor.js:202\nCKEDITOR.scriptLoader.load ckeditor.js:202\nCKEDITOR.resourceManager.load ckeditor.js:206\nf ckeditor.js:208\n(anonymous function) ckeditor.js:209\nn ckeditor.js:219\n(anonymous function) ckeditor.js:219\n(anonymous function) ckeditor.js:396\n(anonymous function) ckeditor.js:207\nn ckeditor.js:202\no ckeditor.js:202\nq ckeditor.js:202\n(anonymous function)\n<\/code><\/pre>\n<p>I am using the following directive<\/p>\n<pre><code>var app = angular.module('Tutorial', [])\n    .config(function($routeProvider, $locationProvider) {\n    $routeProvider\n        .when(\/*routes like this *\/)\n        .otherwise({ redirectTo: '\/' })\n})\n\napp.directive('ckEditor', function() {\n  return {\n    require: '?ngModel',\n    link: function(scope, elm, attr, ngModel) {\n      var ck = CKEDITOR.replace(elm[0]);\n\n      if (!ngModel) return;\n\n      ck.on('pasteState', function() {\n        scope.$apply(function() {\n          ngModel.$setViewValue(ck.getData());\n        });\n      });\n\n      ngModel.$render = function(value) {\n        ck.setData(ngModel.$viewValue);\n      };\n    }\n  };\n});\n<\/code><\/pre>\n<p>Then on my page I have<\/p>\n<pre><code>    \n<\/code><\/pre>\n<p>and<\/p>\n<pre><code>    \n<\/code><\/pre>\n<p>I&#8217;m new to angular and ckeditor, so I don&#8217;t really understand what&#8217;s going on here. I simply need to get the editor onto the page and bound to my model. If anyone knows what could be causing this error, it would help me greatly.<\/p>\n<p>Thanks.<\/p>\n<p>UPDATE: after @sza commented saying that the fiddle worked, I verified that it was in fact something else in my code.<\/p>\n<p>I added a link to the broken page to another page so I could easily navigate to the problem page, and the editor loads correctly.<\/p>\n<pre><code>    onclick=\"location.href=\"\/#\/controller\/view\"\"\n<\/code><\/pre>\n<p>However, whenever I navigate to the location via the url directly, the editor does not work.<\/p>\n<p id=\"rop\"><small>Originally posted 2013-12-01 09:11:01. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>Using the solution from this problem: Bind Ckeditor value to model text in angularjs and rails I get the following error whenever I try to use the directive on my page. Uncaught TypeError: Cannot call method &#8216;unselectable&#8217; of null ckeditor.js:290 a ckeditor.js:290 (anonymous function) ckeditor.js:286 i ckeditor.js:10 CKEDITOR.event.CKEDITOR.event.fire ckeditor.js:12 CKEDITOR.editor.CKEDITOR.editor.fire ckeditor.js:13 CKEDITOR.event.CKEDITOR.event.fireOnce ckeditor.js:12 CKEDITOR.editor.CKEDITOR.editor.fireOnce ckeditor.js:13 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1759","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1759","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=1759"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1759\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=1759"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=1759"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=1759"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}