Roberto Nicchi Posted July 13, 2021 Share Posted July 13, 2021 Hello, in a frame i have three buttons. Each button has a click js event defined as follow. function click(sender, e, eOpts) { var grid = pagamenti_frm.rate_gd; if (grid.editingPlugin.editing) { grid.editingPlugin.completeEdit(); } do something else ... } The code in bold is common to the three buttons and i don't want to repeat it three times. I guess i have to use a custom js function that i can call inside the click event of the buttons. function click(sender, e, eOpts) { execute the common code do something else ... } The custom function must be specific to the frame where the button are placed and will do some work in others components that are in the frame. How to do it ? thanks Quote Link to comment Share on other sites More sharing options...
Sherzod Posted July 13, 2021 Share Posted July 13, 2021 Hello, 1. MainForm -> Script glfn = function(){ alert("Hi") } 2. function click(sender, e, eOpts) { glfn(); } 1 Quote Link to comment Share on other sites More sharing options...
Roberto Nicchi Posted July 13, 2021 Author Share Posted July 13, 2021 1 hour ago, Sherzod said: Hello, 1. MainForm -> Script glfn = function(){ alert("Hi") } 2. function click(sender, e, eOpts) { glfn(); } Thanks. This seems to be a global function. I'm wondering if there's a way to create a function that is specific for a frame where it will be used. In the function there will be code that affects specific objects that are in the frame... This is not essential. it's only for avoid to duplicate code in multiple click js events. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted July 13, 2021 Share Posted July 13, 2021 39 minutes ago, Roberto Nicchi said: if there's a way to create a function that is specific for a frame UniFrame -> ClientEvents -> UniEvents -> function afterCreate(sender) { sender.glfn = function() { alert("Hi") } } UniButton -> ClientEvents -> ExtEvents -> function click(sender, e, eOpts) { sender.owner.FramePanel.glfn(); } 2 Quote Link to comment Share on other sites More sharing options...
Roberto Nicchi Posted July 13, 2021 Author Share Posted July 13, 2021 48 minutes ago, Sherzod said: UniFrame -> ClientEvents -> UniEvents -> function afterCreate(sender) { sender.glfn = function() { alert("Hi") } } UniButton -> ClientEvents -> ExtEvents -> function click(sender, e, eOpts) { sender.owner.FramePanel.glfn(); } Thanks! 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.