simplemodal 与 jhtmlarea 冲突

发布于 2024-10-28 04:30:51 字数 2547 浏览 0 评论 0原文

每当我关闭简单模式对话框时,jHtmlArea 就会停止工作。 我的代码很简单 $.modal.close();

即使我单击 simplemodal 对话框上的关闭按钮,也会发生这种情况。

感谢您的任何帮助。

编辑 我的应用程序使用 ASP.NET MVC3 和通过单击按钮加载的对话框的 html。这意味着我将在每次单击按钮时重新创建对话框。也许我不应该这样做。您能否建议一个更好的工作流程(也许检索原始 Json)。

我尝试过 Eric 的建议,从 onShow 调用 richtexteditor (jhtmlarea),但结果相同。 我也用另一个富文本编辑器(ckeditor)尝试过,但结果仍然相同。

完整代码如下

$(function () {
console.log("beginning ready() for issuesModal");
console.debug("calling tipTip() from ready()..");
$(".tip").tipTip({ maxWidth: "auto", edgeOffset: 10 });

var issuesModal = {
    _targetLink: null,
    _descriptionElem: null,
    _modal: null,
    _modalContainer: $('#basic-modal-content'),
    init: function () {
        console.debug("issuesModal.init()..");

        $("form.edit-issue-form, form.add-issue-form")
                 .submit(function (evt) {
                     evt.preventDefault();
                     hijackForm(this, issuesModal.formLoaded, "html");
                 });
    },
    formLoaded: function (data) {
        console.debug("issuesModal.formLoaded()..");
        issuesModal._modalContainer.html(data);
        issuesModal.doModal(issuesModal._modalContainer);
    },
    doModal: function (elem) {
        console.debug("issuesModal.doModal()..");
        if (issuesModal._modal !== null) {
            $.modal.close();
            issuesModal._modal = null;
        }
        this._modal = $(elem).modal({
            onShow: function (dialog) {
                console.debug("modal form showing..");
                this._descriptionElem = $("#Description");
                 issuesModal.doWysiwyg(this._descriptionElem);
            },
            onClose: function (dialog) {
                console.debug("modal form closing..");
                $.modal.close();
            }
        });
    },
    updateUI: function () {
        console.debug("issuesModal.updateUI()..");
        $(":input[type=submit],[type=reset]").button();

        //$("#issue-name-dropdown").css({ width: 400 }).selectmenu().next().css({ height: 50 })

        $(":input[type=reset]")
        .unbind('click')
        .click(
            function (evt) {
                console.debug("modal form close button clicked..");
                evt.preventDefault();

                $.modal.close();
            }
            );

    },
    doWysiwyg: function (elem) {
        console.debug("issuesModal.doWysiwyg()..");
        $(elem).htmlarea();

    }

};
issuesModal.init();
issuesModal.updateUI();

});

whenever I close my simplemodal dialog, jHtmlArea stops working.
My code is very simple
$.modal.close();

This happens even if I click the close button on simplemodal dialog.

Thanks for any help.

Edit
My app is using ASP.NET MVC3 and the html for the dialog loaded from a button click. This means that I'm re-creating the dialog on each button click. Maybe I shouldn't do this. Can you suggest a better workflow (maybe retrieve raw Json).

I've tried Eric's suggestion to call the richtexteditor (jhtmlarea) from onShow but same results.
I've also tried this with another rich text editor (ckeditor) and still same results.

full code below

$(function () {
console.log("beginning ready() for issuesModal");
console.debug("calling tipTip() from ready()..");
$(".tip").tipTip({ maxWidth: "auto", edgeOffset: 10 });

var issuesModal = {
    _targetLink: null,
    _descriptionElem: null,
    _modal: null,
    _modalContainer: $('#basic-modal-content'),
    init: function () {
        console.debug("issuesModal.init()..");

        $("form.edit-issue-form, form.add-issue-form")
                 .submit(function (evt) {
                     evt.preventDefault();
                     hijackForm(this, issuesModal.formLoaded, "html");
                 });
    },
    formLoaded: function (data) {
        console.debug("issuesModal.formLoaded()..");
        issuesModal._modalContainer.html(data);
        issuesModal.doModal(issuesModal._modalContainer);
    },
    doModal: function (elem) {
        console.debug("issuesModal.doModal()..");
        if (issuesModal._modal !== null) {
            $.modal.close();
            issuesModal._modal = null;
        }
        this._modal = $(elem).modal({
            onShow: function (dialog) {
                console.debug("modal form showing..");
                this._descriptionElem = $("#Description");
                 issuesModal.doWysiwyg(this._descriptionElem);
            },
            onClose: function (dialog) {
                console.debug("modal form closing..");
                $.modal.close();
            }
        });
    },
    updateUI: function () {
        console.debug("issuesModal.updateUI()..");
        $(":input[type=submit],[type=reset]").button();

        //$("#issue-name-dropdown").css({ width: 400 }).selectmenu().next().css({ height: 50 })

        $(":input[type=reset]")
        .unbind('click')
        .click(
            function (evt) {
                console.debug("modal form close button clicked..");
                evt.preventDefault();

                $.modal.close();
            }
            );

    },
    doWysiwyg: function (elem) {
        console.debug("issuesModal.doWysiwyg()..");
        $(elem).htmlarea();

    }

};
issuesModal.init();
issuesModal.updateUI();

});

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦断已成空 2024-11-04 04:30:52

您没有提供任何代码,所以我只能猜测解决方案...

根据 SimpleModal 的工作方式,我建议在 onShow 回调中初始化任何第三方库。

$('#element').modal({
    onShow: function (d) {
        $('textarea', d.data[0]).jHtmlArea(); // general idea, actual syntax may vary
    }
});

华泰

You didn't provide any code, so I can only take a guess at the solution...

With the way SimpleModal works, I suggest initializing any 3rd party libraries in the onShow callback.

$('#element').modal({
    onShow: function (d) {
        $('textarea', d.data[0]).jHtmlArea(); // general idea, actual syntax may vary
    }
});

HTH

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文