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

时间:2021-12-29 19:16:23

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增加回调函数