We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Binding more than one function to an event

Thread ID:

Created:

Updated:

Platform:

Replies:

122118 Feb 17,2016 03:58 AM Feb 18,2016 04:55 AM JavaScript 1
loading
Tags: ejGrid
Greg Gannicott
Asked On February 17, 2016 03:58 AM

Hi.

Is it possible to bind more than one function to an event, at different points in the code.

For example, in one part of the code I would have:

grid.option({ rowSelected: doSomething1 });

Then in another part of the code I would have:

grid.option({ rowSelected: doSomething2 });

And then when the row is selected, both functions trigger.

Using the above style I'm finding that only one is triggering. Is there a way to make both trigger?

Thanks.

Prasanna Kumar Viswanathan [Syncfusion]
Replied On February 18, 2016 04:55 AM

Hi Greg,

Thanks for contacting Syncfusion support.

Yes, we can trigger both the events using jQuery on method, which triggers more than one function on event. In this event, the name should be Plugin + eventName, for example: ejGrid + rowSelected.

Please find the code example and sample:


$(function(){
   
            $("#Grid").ejGrid({
                dataSource: window.gridData,
                allowPaging: true,
                selectionType:"multiple",
                columns: [
                  -----------------------------------------------------
                ]              
            });
   
      $("#Grid").on("ejGridrowSelected", function(e){alert(1)});
      $("#Grid").on("ejGridrowSelected", function(e){alert(2)});


Sample : http://jsplayground.syncfusion.com/30i4sux5

Regards,
Prasanna Kumar N.S.V


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;