Find out which Primefaces component performed an action using jQuery function

2

I want to make a refactoring in my code, and for this I need to get the id of a component that has undergone an action.

My target would be that I have two datatables , and wanted to get id from them and from id define what action to take.

So I have the datatables as shown below

Ihavethefollowingajaxcallswithineachtable.

<p:ajaxevent="rowEditInit" onstart="disableBtnCorrenteExcluir();"/>
<p:ajax event="rowEdit" oncomplete="if (args.validationFailed) disableBtnCorrenteExcluir(); else enableBtnCorrenteExcluir();"/>
<p:ajax event="rowEditCancel" oncomplete="enableBtnCorrenteExcluir();" />

For each table I run methods to block the Add Track, Edit Effect, and Delete Effect buttons. What is in question is, if when I execute the above methods on the specific events of Primefaces , will it be able to get which object called it?

How can I do this?

    
asked by anonymous 08.10.2014 / 20:11

1 answer

1

I do not know if it's exactly what you expect, but when treating any event (such as onclick ) in an element that is within datatable , you can use the following JavaScript code to retrieve id from table:

$(this).closest('.ui-datatable').attr('id');

Remembering that this in this context refers to the button that was clicked.

The above code locates in the "parent" elements of the clicked element, the first containing the ui-datatable class.

This works on both a% inline tag in the element tag, and in a function added with jQuery.

    
08.10.2014 / 21:31