This is a migrated thread and some comments may be shown as answers.

[Solved] capture cancel click

3 Answers 113 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Marco
Top achievements
Rank 1
Marco asked on 06 Apr 2010, 11:11 AM
hello I'm trying to capture cancel button click maintain the default functionality and call a custom java script.

i have tried to use but this is only call on load.

 $('.t-grid-cancel').click(function() {
            myJSFunction();
        });

i think this happens because is already bounded to your event.
How can i maintain your logic and add some custom logic?

Best Regards
Marco

3 Answers, 1 is accepted

Sort by
0
Peter
Top achievements
Rank 1
answered on 06 Apr 2010, 11:27 AM
Hi,

You can try this code snippet to achieve your goal:
 $('.t-grid-cancel').bind('click',function() { 
            myJSFunction(); 
        }); 

Regards,
Peter


0
Marco
Top achievements
Rank 1
answered on 06 Apr 2010, 11:56 AM
I Peter Thanks for you reply but unfortunately it did't work!

the binding is done on page load but after that the function is never called.

more suggestions?

regards Marco
0
Alex Gyoshev
Telerik team
answered on 06 Apr 2010, 12:05 PM
Hi Marco,

Because the cancel buttons are dynamically created and deleted, you need to use a live event handler, instead of the classic binding, like this:

$('.t-grid-cancel').live('click',function() {
    myJSFunction();
});

This will, however, fire the event after the grid has closed the editing interface. If you need to perform the processing before the editing is canceled, you need to perform a slightly different trick, like this:

$('.t-grid-edit').live('click', function(e) {
    $('.t-grid-cancel').click(function() {
        alert(1);
    });
});

This will attach click handlers on cancel buttons when edit buttons are clicked - thus, the click event of the cancel buttons will fire before the grid processing occurs.

Kind regards,
Alex Gyoshev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Grid
Asked by
Marco
Top achievements
Rank 1
Answers by
Peter
Top achievements
Rank 1
Marco
Top achievements
Rank 1
Alex Gyoshev
Telerik team
Share this question
or