0

Override onClick for a tab

asked 2022-03-24 19:58:49 +0800

softteam gravatar image softteam
130 1 8

Hi, I got this script to override onClick tab event in order to use an onCustom event:

        zk.afterLoad("zul.tab", function () {  
            var _xTab = {}; 
            zk.override(zul.tab.Tab.prototype, _xTab, { 
                doClick_: function() {
                    this.fire("onCustom", null, {toServer:true}); 
                } 
             }); 
        });

Now, I want to use this script only for a specific tab. I tried this, but onCustom event is never fired:

<tab  onCustom="@command('seleccionarTabTrazabilidad',item=item, evento=event.getTarget())">
 <attribute w:name="_doClick"><![CDATA[
       function () {
        this.$_doClick(); //call the original method
        this.fire("onCustom", null, {toServer:true}); 
      }
  ]]>
</attribute>
</tab>

How should I do that?

Thank you!

Javier

delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2022-03-25 16:51:45 +0800

MDuchemin gravatar image MDuchemin
2535 1 6
ZK Team

Hi there!

The way I'd approach that for portability would be with a custom class: https://zkfiddle.org/sample/3aeced6/9-Another-new-ZK-fiddle

Otherwise, you'd have to go for this method to do it as an attribute: https://zkfiddle.org/sample/3aeced6/11-Another-new-ZK-fiddle

which is almost the same as what you were doing, with 2 small wrinkles:

1 - using doClick instead of doClick

2 - not calling super (super will start the regular doClick workflow, which I understand you don't want in this case?)

link publish delete flag offensive edit
Your answer
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
1 follower

RSS

Stats

Asked: 2022-03-24 19:58:49 +0800

Seen: 7 times

Last updated: Mar 25 '22

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