Jump to content

Custom js function ? Probably is trivial task but i don't know how to do it ...


Roberto Nicchi

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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();
}

 

  • Like 2
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...