Prashobh
Prashobh

Reputation: 9544

How to enable a click event on first colum of ng-grid on page load

How to enable a click event on first column of ng-grid on page load.

All fields are coming dynamically .And i used ng -grid

i tried these

$('.colt0').find('.icon-sort').click();
$('.colt0').find('.icon-sort').trigger('click');
$('.colt0').trigger('click');
$('.colt0').on('trigger' ,'click');

but not working....

Please suggest.

Upvotes: 1

Views: 477

Answers (2)

leonardeveloper
leonardeveloper

Reputation: 1853

Try this:

    $(document).on('click', '.colt0', function(){
    //do something
    });

Upvotes: 1

Jonas G. Drange
Jonas G. Drange

Reputation: 8845

You should be using delegated events for this:

$(".colt0").on("click", ".icon-sort", function(event){
    // will fire for dynamically loaded .icon-sorts
});

Delegated events have the advantage that they can process events from descendant elements that are added to the document at a later time. ...

and

... In addition to their ability to handle events on descendant elements not yet created, another advantage of delegated events is their potential for much lower overhead when many elements must be monitored.

Read more here.

Upvotes: 1

Related Questions