讀取模板,放到ueditor中進行編輯javascript
@model WeiXin_Shop.Models.WX_GoodsDetails @Html.Partial("_MasterPage") @{ ViewBag.Title = "Edit"; } @using (Html.BeginForm()) { @Html.ValidationSummary(true) @Html.HiddenFor(model => model.id) <div class="editor-label"> @Html.LabelFor(model => model.htmlStr) 模板:<a id="temp">模板事例</a> </div> <br /> <body> <div> @Html.TextAreaFor(model => model.htmlStr, new { id = "editor", style = "width:100%;height:500px;" }) </div> </body> } <script type="text/javascript"> //實例化編輯器 //建議使用工廠方法getEditor建立和引用編輯器實例,若是在某個閉包下引用該編輯器,直接調用UE.getEditor('editor')就能拿到相關的實例 //var ue = UE.getEditor('editor'); var editor = new baidu.editor.ui.Editor({ UEDITOR_HOME_URL: '/Content/ueditor/',//配置編輯器路徑 iframeCssUrl: '/Content/ueditor/themes/iframe.css',//樣式路徑 initialContent: "",//初始化編輯器內容 autoHeightEnabled: true,//高度自動增加 minFrameHeight: 500//最小高度 }); editor.render('editor'); $('#temp').click(function () { $.get('../Template/GoodsLayout.txt').success(function (content) { editor.setContent(content); }); }) </script>