0

Overriding a function in sel.js (3.6)

asked 2011-01-31 06:41:42 +0800

xmedeko gravatar image xmedeko
1031 1 16
http://xmedeko.blogspot.c...

Hi,

I have found, that the empty listbox vertical size computation is not correct in the sel.js (zul.jar). I subtract -4 from the header:

/* Height of the head row. If now header, defval is returned. */
zk.Selectable.prototype._headHgh = function (defVal) {
	var hgh = this.head ? this.head.offsetHeight - 4 : 0;
	if (this.paging) {
		var pgit = $e(this.id + "!pgit"), pgib = $e(this.id + "!pgib");
		if (pgit) hgh += pgit.offsetHeight;
		if (pgib) hgh += pgib.offsetHeight;
	}
	return hgh ? hgh: defVal;
};

and now it works fine. However, I do not know, how to load this piece of javascript just right after the sel.js is loaded. Is there such an option in ZK 3.6? Maybe zk.addBeforeInit()? Or do I have to hack the file sel.js in the zul.jar?

Thanks with any help
Andy

delete flag offensive retag edit

8 Replies

Sort by ยป oldest newest

answered 2011-02-04 03:12:10 +0800

xmedeko gravatar image xmedeko
1031 1 16
http://xmedeko.blogspot.c...

Just bumping this thread ... does anybody know, it if there is an simple way, how to override just one JavaScript widget function in ZK 3.6.5? Thanks.

link publish delete flag offensive edit

answered 2011-02-10 18:36:53 +0800

RyanWu gravatar image RyanWu
533 2
about.me/flyworld

the way you've used is correct, in ZK 3.6.5, we only save component info on the server, so the concern of javascript is handling DOM structure.

link publish delete flag offensive edit

answered 2011-02-11 01:13:49 +0800

xmedeko gravatar image xmedeko
1031 1 16
http://xmedeko.blogspot.c...

updated 2011-02-11 10:05:47 +0800

Hi RyanWu,
thanks for the answer. But my concern is, where to put my zk.Selectable.prototype._headHgh() function. I do not want to change the zul.jar, bacause it's not good for ZK upgrades. And the sel.zul is loaded dynamically when the list box is used first. So I would like to know, it there is some some kind of event of hook "afterload" of JavaScript modules, where I can put my zk.Selectable.prototype._headHgh().

Thanks

link publish delete flag offensive edit

answered 2011-02-14 08:36:33 +0800

RyanWu gravatar image RyanWu
533 2
about.me/flyworld

you can do like this

zk.addInitLater(function () {
   // do something...
});

link publish delete flag offensive edit

answered 2011-02-15 02:21:32 +0800

xmedeko gravatar image xmedeko
1031 1 16
http://xmedeko.blogspot.c...

updated 2011-02-15 02:23:35 +0800

Hi Ryan,

zk.addInitLater does not help me. When my page is loaded, there is no listbox, so the sel.js is not loaded. Then the page is changed by Executions.createComponents() and Include component. The sel.js is loaded when the first listbox is displayed and it depends on the user action. So I need some hook "afterLoad("sel.js", function())" or something like that.

I find this on-demand loading of *.js files great, but I cannot find any "afterLoad" and "beforeLoad" hooks.

link publish delete flag offensive edit

answered 2011-02-20 20:59:49 +0800

RyanWu gravatar image RyanWu
533 2
about.me/flyworld

you can use zk.load("zul.sel", function () {})

link publish delete flag offensive edit

answered 2011-02-21 01:46:19 +0800

xmedeko gravatar image xmedeko
1031 1 16
http://xmedeko.blogspot.c...

Hi Ryan,

the correct function is

zk.addOnLoad("zul.sel", function() {});

Thanks very much for your help and pointing me to the right direction.

link publish delete flag offensive edit

answered 2011-02-24 07:26:25 +0800

xmedeko gravatar image xmedeko
1031 1 16
http://xmedeko.blogspot.c...

FYI the correct patch for the sel.zul is:

zk.Selectable.prototype._headHgh = function (defVal) {
	var hgh = this.head ? this.head.offsetHeight : 0; 
	if (hgh > 8) { // correction: -4 if possible (if head exists and is visible) 
		hgh -= 4;
	}
	if (this.paging) {
		var pgit = $e(this.id + "!pgit"), pgib = $e(this.id + "!pgib");
		if (pgit) hgh += pgit.offsetHeight;
		if (pgib) hgh += pgib.offsetHeight;
	}
	return hgh ? hgh: defVal;
};

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2011-01-31 06:41:42 +0800

Seen: 362 times

Last updated: Feb 24 '11

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More