Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Dynamic action on apex_item.switch

Scott WesleyMay 15 2019 — edited May 15 2019

I have a classic report rendering one column using the apex_switch item API, and I would like a dynamic action to capture click/change, and give me the relevant ID/value.

pastedImage_8.png

My SQL contains

APEX_ITEM.SWITCH(

 p\_idx => 42

 ,p\_value => ie.my\_val

 ,p\_on\_value => 'Y'

 ,p\_on\_label => 'Include'

 ,p\_off\_value => 'N'

 ,p\_off\_label => 'Exclude'

 ,p\_item\_label => 'Include'

 ,p\_item\_id => 'include\_'||i.id

)

With an onClick DA using this jQuery selector

.apex-item-group--switch

And the following JavaScript action returns the values I need

console.log('val:'+$(this.triggeringElement).find('input[name=f42]').val());

console.log($('.apex-item-group--switch').find('input[name=f42]').prop('id').substr(8));

However, the action is triggered twice, once for each value

If I change the value, the browser console in debug mode returns:

Dynamic Action Fired: correspondence (NATIVE_JAVASCRIPT_CODE) {triggeringElement: div#include_837926_group.apex-button-group.apex-item-group.apex-item-group--switch, affectedElements: jQuery.fn.init(1), action: {…}, browserEvent: j…y.Event, data: undefined, …}

val:N

837926

Dynamic Action Fired: correspondence (NATIVE_JAVASCRIPT_CODE) {triggeringElement: div#include_837926_group.apex-button-group.apex-item-group.apex-item-group--switch, affectedElements: jQuery.fn.init(1), action: {…}, browserEvent: j…y.Event, data: undefined, …}

val:Y

837926

If I click on the same value, it still executes twice, but with the same value.

What should I adjust to have an action that only indicates the new value? Is there a cleaner way of accomplishing this task?

APEX 18.2

Cheers

This post has been answered by Oleh Tyshchenko on May 15 2019
Jump to Answer
Comments
Post Details
Added on May 15 2019
2 comments
1,545 views