在角度jS函数中初始化tinymce会第二次抛出错误

时间:2016-07-06 12:22:59

标签: javascript jquery angularjs tinymce

通过动态传递textarea id来初始化angular js init函数中的tinymce编辑器

下面的HTML内容。

<div ng-app="rootapp" ng-controller="rootcontroller">
    <div id="div1">
        ---first content--------
        <div  ng-controller="editorController" ng-init="getInformation('SettingsDuplicates')">
            <textarea id=" SettingsDuplicates"></textarea>
        </div>
    </div>

    <div id="div2">
        ---first content--------
        <div  ng-controller="editorController" ng-init="getInformation('new1')">
            <textarea id=" new1"></textarea>
        </div>
    </div>
</div>

controller.js功能

$scope.getInformation = function (from) {
    tinymce.editors = [];
    tinymce.init({
        mode: "specific_textareas",
        selector: "textarea#" + from,

        height: 300,
        menubar: false,
        plugins: [
            'advlist autolink link image lists charmap print preview hr anchor pagebreak spellchecker',
            'searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking',
            'save table contextmenu directionality emoticons template paste textcolor'
        ],
        theme: 'modern',
        toolbar1: 'bold italic | underline | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image',
        image_advtab: true,
        templates: [
            { title: 'Test template 1', content: 'Test 1' },
            { title: 'Test template 2', content: 'Test 2' }
        ]
    });
    //}
    $scope.screenFrom = from;
    //some service call
}

第一个textarea转换为编辑器iefine。但第二个textarea没有转换为编辑器,它正在抛出问题

TypeError: Cannot read property 'childNodes' of undefined at g (angular.min.js:58)

0 个答案:

没有答案