首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ASP.NET MVC模板问题

ASP.NET MVC模板问题
EN

Stack Overflow用户
提问于 2011-06-18 05:49:24
回答 1查看 293关注 0票数 0

我尝试创建模板,这个模板应该来自1个元素-文本区,但是这个文本区应该扩展到TinyMCE控件。我尝试通过下面的ascx控件来做到这一点:

代码语言:javascript
复制
<textarea id="SubComment" name="SubComment" style="width: 80%">
<% = Html.Encode(ViewData.TemplateInfo.FormattedModelValue) %></textarea>
   <script type="text/javascript" src="/Scripts/jquery-1.3.2.min.js"></script>
   <script type="text/javascript">
        tinyMCE.init({
            // General options
            mode: "textareas",
            theme: "advanced",
            plugins: "spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,nonbreaking,xhtmlxtras,template,imagemanager,videoupload",

            // Theme options
            theme_advanced_buttons1: <% = txtAdvButtons %>,
            theme_advanced_buttons2: "tablecontrols",
            theme_advanced_buttons3: "",
            theme_advanced_toolbar_location: "top",
            theme_advanced_toolbar_align: "left",
            theme_advanced_statusbar_location: "",
            theme_advanced_resizing: true,
            onchange_callback: "changed",

            // Example content CSS (should be your site CSS)
            content_css: "css/example.css",

            // Drop lists for link/image/media/template dialogs
            template_external_list_url: "js/template_list.js",
            external_link_list_url: "js/link_list.js",
            external_image_list_url: "js/image_list.js",
            media_external_list_url: "js/media_list.js",

            // Replace values for the template plugin
            template_replace_values: {
                username: "Some User",
                staffid: "991234"
            },

            setup: function(editor) {
                editor.addButton('myupload', {
                    title: 'Insert image',
                    image: '/tiny_mce/plugins/imagemanager/pages/im/img/insertimage.gif',
                    onclick: function() {
                        mcImageManager.upload({
                            path: '{0}',
                            onupload: function(info) {
                                var i, html = '';

                                for (i = 0; i < info.files.length; i++)
                                    html += '<img src="' + info.files[i].url + '" />';

                                editor.execCommand('mceInsertContent', false, html);
                            }
                        });
                    }
                });
            }

        });
</script>

但是当我尝试使用这个模板时,我看到了简单的文本区域。如何应用这个javascript扩展(它可以在ascx控制之外正常工作)?谢谢

EN

回答 1

Stack Overflow用户

发布于 2011-06-18 06:22:03

因此,我阅读了tinyMCE的文档,发现您在那里发布的代码应该放在Head标记或其他脚本文件中。

将您的文本区域更改为:

代码语言:javascript
复制
<textarea name="SubComment" class="tinyMCETextArea" style="width: 80%">

在您的tinyMCE初始化代码中:

代码语言:javascript
复制
$(function(){
    tinyMCE.init({
        /// all your options
        editor_selector: "tinyMCETextArea",
        /// More stuff
    });
});
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6392206

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档