DWZ(JUI)的lookupGroup增加回调函数

简介:

DWZ 是一个很好的富客户端框架

lookupGroup也是一个必用到的东东,但没有回调函数,后期处理相当的不便。

修改其dwz.database.js

增加几行,就能实行一个很好的回调。

使用就方便了,

如:

源代码

<input type="hidden" value="H2" name="roleid" id="roleid">

<input type="hidden" value="H2" name="roleid.id" id="roleid_id">

<input type="text" name="roleid.Name" readonly="" class="input input-large required textInput readonly" value="CEO">

<a width="400" lookupgroup="roleid" warn="请选择部门" href="index.php?........." callback="roleid_callback" class="btnLook">选择部门</a>

<script language="javascript">

function roleid_callback()

{

    jQuery("#roleid").val(jQuery("#roleid_id").val());

}

</script>

 

修改的代码如下

源代码

 

(function($){

    var _lookup = {currentGroup:"", suffix:"", $target:null, pk:"id",callback:null};

    var _util = {

        _lookupPrefix: function(key){

            var strDot = _lookup.currentGroup ? "." : "";

            return _lookup.currentGroup + strDot + key + _lookup.suffix;

        },

        lookupPk: function(key){

            return this._lookupPrefix(key);

        },

        lookupField: function(key){

            return this.lookupPk(key);

        }

    };

 

    $.extend({

        bringBackSuggest: function(args){

            var $box = _lookup['$target'].parents(".unitBox:first");

            $box.find(":input").each(function(){

                var $input = $(this), inputName = $input.attr("name");

                for (var key in args) {

                    var name = (_lookup.pk == key) ? _util.lookupPk(key) : _util.lookupField(key);

                    if (name == inputName) {

                        $input.val(args[key]);

                        break;

                    }

                }

            });

            var callback = _lookup['callback'];     

            try

            {

                eval_r(callback+"();");

            }

            catch (e){}

        },

        bringBack: function(args){

            $.bringBackSuggest(args);

            $.pdialog.closeCurrent();

        }

    });

 

    $.fn.extend({

        lookup: function(){

            return this.each(function(){

                var $this = $(this), options = {mask:true,

                    width:$this.attr('width')||820, height:$this.attr('height')||400,

                    maxable:eval_r($this.attr("maxable") || "true"),

                    resizable:eval_r($this.attr("resizable") || "true")

                };

                $this.click(function(event){

                    _lookup = $.extend(_lookup, {

                        currentGroup: $this.attr("lookupGroup") || "",

                        callback: $this.attr("callback"), 

                        suffix: $this.attr("suffix") || "",

                        $target: $this,

                        pk: $this.attr("lookupPk") || "id"

                    });

                    Var   url    = ($this.attr("href")).replaceTmById($(event.target).parents(".unitBox:first"));

                    if (!url.isFinishedTm()) {

                        alertMsg.error($this.attr("warn") || DWZ.msg("alertSelectMsg"));

                        return false;

                    }

                    $.pdialog.open(url, "_blank", $this.attr("title") || $this.text(), options);

                    return false;

                });

            });

        },

   

})(jQuery);

 

如果您觉得文章有用,也可以给水发个微信小额红包鼓励鼓励!!!

本文转自左正博客园博客,原文链接:http://www.cnblogs.com/soundcode/p/5520236.html,如需转载请自行联系原作者


相关文章
|
7月前
【sd.js】凯哥版(逐步废弃、逐渐日落2024.01.02)
【sd.js】凯哥版(逐步废弃、逐渐日落2024.01.02)
|
7月前
sd.js 2.0封装:更加简化请求传参内容(逐步废弃、逐渐日落2024.01.02)
sd.js 2.0封装:更加简化请求传参内容(逐步废弃、逐渐日落2024.01.02)
|
前端开发
前端项目实战玖拾叁react-admin+material ui-踩坑-List的用法之debounce设置显示时间
前端项目实战玖拾叁react-admin+material ui-踩坑-List的用法之debounce设置显示时间
79 0
|
JavaScript
JS(Dom事件操作)第十九
JS(Dom事件操作)第十九
190 0
|
JavaScript 前端开发 数据处理
带你读《现代Javascript高级教程》三十三、页面生命周期: DOMContentLoaded, load, beforeunload, unload(3)
带你读《现代Javascript高级教程》三十三、页面生命周期: DOMContentLoaded, load, beforeunload, unload(3)
|
前端开发 JavaScript API
带你读《现代Javascript高级教程》三十三、页面生命周期: DOMContentLoaded, load, beforeunload, unload(2)
带你读《现代Javascript高级教程》三十三、页面生命周期: DOMContentLoaded, load, beforeunload, unload(2)
|
JavaScript 前端开发 API
带你读《现代Javascript高级教程》三十三、页面生命周期: DOMContentLoaded, load, beforeunload, unload(1)
带你读《现代Javascript高级教程》三十三、页面生命周期: DOMContentLoaded, load, beforeunload, unload(1)
|
前端开发
前端工作总结142-element上传组件时候的钩子--event里面有数据参数
前端工作总结142-element上传组件时候的钩子--event里面有数据参数
79 0
前端工作总结142-element上传组件时候的钩子--event里面有数据参数
|
JavaScript
关于jQuery中toggle参数callback函数提前执行问题
关于jQuery中toggle参数callback函数提前执行问题
101 0
|
JavaScript 前端开发
#yyds干货盘点# 【js学习笔记三十七】事件冒泡
#yyds干货盘点# 【js学习笔记三十七】事件冒泡
104 0
#yyds干货盘点# 【js学习笔记三十七】事件冒泡