【问题标题】:TinyMCE doesn't initialize using ng-repeatTinyMCE 不使用 ng-repeat 初始化
【发布时间】:2014-04-16 08:26:49
【问题描述】:

当我想附加一个链接到 tinyMCE 所见即所得的文本区域时,我遇到了问题。 tinyMCE 没有时间初始化,因此解决方案可能是等待 ng-repeat 结束。但我现在不知道怎么和 tinyMCE 不使用角度所以..

需要你的帮助。

玩得开心。

【问题讨论】:

    标签: javascript angularjs tinymce


    【解决方案1】:

    看看这个

    Working Demo

    html

    <div ng-app="myApp" ng-controller="PostController">
        <br/>
        <textarea ng-model="mypost" ui-tinymce="tinymceOptions"></textarea>
        <br/>
        <input type="button" value="Submit" ng-click="submit()"/>
        <br/>
        <ul>
            <li ng-repeat="post in posts | orderBy:orderProp:true">
                <input type="button" value="Edit" ng-click="edit=!edit;newpost=post.content"/>
                <input ng-hide="edit" type="button" value="Delete" ng-click="deletepost(post)"/>
                <br />
                <div ng-hide="edit" style="white-space: pre-wrap"><ANY ng-bind-html-unsafe="post.content"></ANY></div>
                <div ng-show="edit">
                    <textarea ng-model="newpost" ui-tinymce="tinymceOptions"></textarea>
                    <input type="button" value="Submit" ng-click="editpost(post, newpost);edit=!edit" />
                </div>
                <br /><br /><br/>
            </li>
        </ul>
    </div>
    

    脚本

    var myApp = angular.module('myApp', ['ui.tinymce']);
    
    function PostController($scope) {
        $scope.posts = [];
        $scope.time = 1;
        $scope.orderProp = 'pseudo_time';
    
        $scope.tinymceOptions = { menubar: false };
    
        $scope.submit = function() {
            newpost = {"content": $scope.mypost, "pseudo_time": $scope.time++};
            $scope.posts.push(newpost);
        };
        $scope.editpost = function(post, newpost) {
            var index = jQuery.inArray(post, $scope.posts);
            $scope.posts[index].content = newpost;
        };
        $scope.deletepost = function(post) {
            if (confirm("Delete Answer?") == true) {
                var index = jQuery.inArray(post, $scope.posts);
                $scope.posts.splice(index, 1);
            }
        };
    }
    

    【讨论】:

    • 谢谢,所以这是使用角度 tinymce 初始化。但是演示似乎不像您的预览图片那样正常工作。我错过了什么吗?编辑:当然 jsfiddle 不加载 tinymce.ui。好的,所以我要尝试一下。如果它有效,我会验证你的答案。
    • 完美!它甚至可以在 chrome、firefox、safari、opera 和 IE6 上运行。最后一个笑话...
    猜你喜欢
    • 2013-09-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多