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

Posted 左正

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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);

以上是关于DWZ(JUI)的lookupGroup增加回调函数的主要内容,如果未能解决你的问题,请参考以下文章

给jui(dwz)的navTab换一套漂亮的图标

给jui(dwz)的toolbar添加漂亮的图标

DWZ(JUI) 教程 跨域请求 iframeNavTab

DWZ-JUI 树形Checkbox组件 无法一次获取所有选中的值的解决方法

dwz框架

DWZ-JUI+UEditor第二次不显示,UEditor异步加载第二次不显示的解决方案