带有jquery widget插件MVC的可重用框架

时间:2015-04-19 23:22:45

标签: jquery model-view-controller plugins widget

我需要在mvc vb中创建一个可以在所有proyect中重用的框架或对象。

填写要搜索的字段数据。然后按下按钮1 这显示了一个显示posibles结果的jquery弹出窗口

当我选择结果时,弹出窗口关闭并将结果填入框架中,然后您可以按下按钮2打开另一个弹出窗口显示人员详细信息(此弹出窗口是另一个局部视图)< / p>

问题是我需要捕捉框架上按钮的de事件,我创建一个包含框架的部分视图,但是不能交出点击事件,那么我认为更好的方法是制作一个控制点击回调的jquery小部件插件:

$ .tidget(“mk.Frame”,{

options: {
    Botones: {
        Limpiar: true,
        Nuevo: true,
        Detalle: true
    }
},

_create: function () {

    var $ob = $(this.element)
    var t = this


    $ob.load('URL_PARTIAL_VIEW_FRAME', function (html) {
        if (!t.options.Botones.Limpiar) {
            $ob.find('#pw_fra_pac_Limpiar').hide(true)
        }
        if (!t.options.Botones.Nuevo) {
            $ob.find('#pw_fra_pac_Nuevo').hide(true)
        }
        if (!t.options.Botones.Detalle) {
            $ob.find('#pw_fra_pac_Detalle').hide(true)
        }
    })






    this._on(this.element, {
        "click": function (event) {

            if (event.toElement.type == "button" || event.toElement.type == "submit" || event.target.offsetParent.type == "button") {
                if (event.toElement.getAttribute("id") == "pw_fra_pac_Limpiar") {
                    this._trigger("Limpio")
                }
                if (event.toElement.getAttribute("id") == "pw_fra_pac_Nuevo") {
                    this._trigger("Nuevo")
                }
                if (event.toElement.getAttribute("id") == "pw_fra_pac_Buscar") {
                    this._trigger("Buscar")
                }
                if (event.toElement.getAttribute("id") == "pw_fra_pac_Detalle") {
                    this._trigger("Detalle")
                }
                return true
            }
            event.preventDefault();
        }
    });


},

})

这是最好的方法吗?!!!!!一些想法?!!我是网络编程的新手。

由于

0 个答案:

没有答案