Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Model view controller 提交后重置tinyMCE框_Model View Controller_Tinymce - Fatal编程技术网

Model view controller 提交后重置tinyMCE框

Model view controller 提交后重置tinyMCE框,model-view-controller,tinymce,Model View Controller,Tinymce,我有如下MVC视图 @model Site.SupportItems.SiteAditionalInformation @using Site.Helpers.Extenders; @{ Response.CacheControl = "no-cache"; } <div> @using (Html.BeginForm("SaveSiteAdditionalInformation", "Support", FormMethod.Post, new { @Id = "f

我有如下MVC视图

@model Site.SupportItems.SiteAditionalInformation
@using Site.Helpers.Extenders;
@{
    Response.CacheControl = "no-cache";
}
<div>
    @using (Html.BeginForm("SaveSiteAdditionalInformation", "Support", FormMethod.Post, new { @Id = "frmSiteInformation" }))
 {
        @Html.ValidationSummary(true)
        <fieldset>
            <legend>Site Aditional Information</legend>
            <div class="site-PO-footer-outline-left-comment">
                <div class="site-item-outline">
                    <div class="site-label-left ui-corner-all">
                        @Html.LabelFor(model => model.Office)
                    </div>
                    <div class="site-detail">
                        @Html.DropDownListFor(x => x.Office, Model.Offices.ToSelectList("ValueSelected", "DisplayValueSelected", Model.Office))
                        @Html.ValidationMessageFor(model => model.Office)
                    </div>
                </div>
                <div class="site-item-outline">
                    <div class="site-label-left ui-corner-all">
                        @Html.LabelFor(model => model.AdditionalInformation)
                    </div>
                    <div class="site-detail">
                        @Html.TextAreaFor(model => model.AdditionalInformation, new { @Class = "ui-site-rtb" })
                        @Html.ValidationMessageFor(model => model.AdditionalInformation)
                    </div>
                </div>
            </div>
            <p>
                <input type="submit" value="Save" id="btnSubmit" />
            </p>
        </fieldset>
 }
    <script type="text/javascript">
        $(function ()
        {
            var thisTab = $(Globals.ActiveTabId());
            var previousSelectedOffice;
            $('#Office', thisTab).click(function ()
            {
                previousSelectedOffice = $('#Office', thisTab).val();

            }).change(function (e)
            {
                var setNewContent = function ()
                {
                    $('#loading-Panel').Loading('show');
                    $.ajax('@Url.Action("GetSiteSpecificText")', {
                        data: { Office: $('#Office', thisTab).val(),
                            rnd: Math.random() * 10000
                        },
                        cached: false,
                        success: function (response)
                        {
                            if (response != null)
                            {
                                $('#AdditionalInformation', thisTab).html(response);
                            }
                            else
                                $('#AdditionalInformation', thisTab).html('');

                            $('#loading-Panel').Loading('hide');
                        }
                    });
                };
                if (tinyMCE.activeEditor.isDirty())
                {
                    $('<div/>').text('The Text has changed for the Additional Information. Would you like to save?').dialog({
                        title: 'Text has Changed',
                        buttons: {
                            'Ok': function ()
                            {
                                $('#loading-Panel').Loading('show');
                                var beforeSave = $('#Office', thisTab).val();
                                $('#Office', thisTab).val(previousSelectedOffice);
                                $('#frmSiteInformation', thisTab).trigger('submit');
                                $('#Office', thisTab).val(beforeSave);
                                setNewContent();
                                $(this).dialog('close');
                            },
                            'Cancel': function ()
                            {
                                $(this).dialog('close');
                                $('#Office', thisTab).val(previousSelectedOffice);
                            }
                        }
                    });
                }
                else
                {
                    setNewContent();
                }
            });
            $('#frmSiteInformation', thisTab).submit(function ()
            {
                tinyMCE.triggerSave();
                var data = $('#frmSiteInformation', thisTab).serializeObject();
                $('#loading-Panel').Loading('show');
                $.ajax($(this).attr('action'), {
                    type: 'POST',
                    dataType: 'json',
                    contentType: 'application/json; charset=utf-8',
                    data: JSON.stringify(data),
                    success: function (data)
                    {
                        if (data.SaveResult)
                            $('<div/>').text('Save Successful for' + $('#Office option:selected', thisTab).text())
                        .dialog({
                            title: 'Save Successful',
                            buttons: {
                                'Ok': function ()
                                {
                                    $(this).dialog('close');

                                }
                            }
                        });
                        $('#loading-Panel').Loading('hide');
                    }
                });
                return false;
            });
        });
    </script>
</div>

感谢您的帮助。

@Thariama该错误与对象上的n.length为空有关。当我查看Tinymce.js上的一些代码时,我看到了Tinymce.editors,其中大约有4个为我在DropDown上所做的每一个更改初始化了一个。你可以使用Tinymce的开发版本并包含Tinymce而不是Tinyme.js。这样更容易找到你的问题。
var setNewContent = function ()
                {
                    $('#loading-Panel').Loading('show');
                    $.ajax('@Url.Action("GetSiteSpecificText")', {
                        data: { Office: $('#Office', thisTab).val(),
                            rnd: Math.random() * 10000
                        },
                        cached: false,
                        success: function (response)
                        {
                            tinymce.execCommand('mceRemoveEditor', false, 'AdditionalInformation');
                            if (response != null)
                            {
                                $('#AdditionalInformation', thisTab).html(response);
                            }
                            else
                                $('#AdditionalInformation', thisTab).html('');

                            tinymce.execCommand('mceAddControl', false, 'AdditionalInformation');
                            $('#loading-Panel').Loading('hide');
                        }
                    });
                };