Forum Stats

  • 3,839,680 Users
  • 2,262,526 Discussions
  • 7,901,038 Comments

Discussions

Trigger Dynamic Action from Popup Window

devlarry
devlarry Member Posts: 64 Blue Ribbon
edited Oct 2, 2015 3:35PM in APEX Discussions

I have a pop up window which a user chooses a name from a report (address book). When they select the user the name, phone, and email populate the main form. The pop up has JavaScript that populates the opener.document fields. I created a Dynamic Action that uses the on change event to run a PL/SQL code to fill in the users supervisors information. The problem is the setting the fields in the opener from the popup appears to not trigger the onchange event. If I manually enter the information the process triggers and works. I have tried several ways to set the value using the $s() and document.getElement... but still no onchange trigger. I googled to see if someone else encountered this and had a solution but did not find any that works. I came across the apex.event.trigger but it fires it the pop up window and not in the opener window. I could not find any way to reference through javascript, jquery, or apex the "opener.window" to trigger the change.

I was wondering if anyone had any solution or thoughts of a solution?

Thanks in advance for all assistance.

Lawrence

Oracle APEX 4.2.6

Database 11g

Chrome Browser

Tagged:

Answers

  • Sergio Vega
    Sergio Vega Member Posts: 153 Red Ribbon
    edited Sep 11, 2015 9:14AM

    Hi Lawrence,

    You can use a dynamic action that fires with a custom event in opener page and trigger it from popup using "parent". The javascript code should be something like this:

    parent.$('#item_id').trigger("someevent");

    2015-09-11_15-10-05.png

    Hope this helps,

    Sergio

  • devlarry
    devlarry Member Posts: 64 Blue Ribbon
    edited Sep 11, 2015 2:43PM

    Thanks Seregio but it didn't work either. I am setting the parent fields via javascript from the pop up. It appears the the change event is not happening. If I set the field manually on the parent the change event triggers.

  • Sergio Vega
    Sergio Vega Member Posts: 153 Red Ribbon
    edited Sep 11, 2015 4:15PM

    Ok, do you really need to fire the action when item changes? Otherwise you can fire dynamic action for event "Dialog closed".

  • devlarry
    devlarry Member Posts: 64 Blue Ribbon
    edited Oct 2, 2015 1:38PM

    Sergio,

    I have a dynamic action that fires when the user enters a name in the assigned field. It queries a table for the supervisor name and populates the name, phone and email field automatically. When I type in the field it works perfectly. I have a popup window that shows our address book. The user can search for a name and click on it to populate the assigned field. I do this so that we have standard entry of the assigned name. e.g. entry of Daniel Smith vs Dan Smith. But what is happening is that the "change" event does not trigger when I populate the fields via javascript from the popup. Even using some of the javascript to trigger on the parent window does not work. Right now the user has to enter both user and supervisor. This is not a critical issue but would be nice to solve as I can use this process in other applications in several situations.

  • Sergio Vega
    Sergio Vega Member Posts: 153 Red Ribbon
    edited Oct 2, 2015 2:10PM

    Hi Lawrence,

    You should add a new dynamic action assigned to "custom event"  that have same actions of your actual "on click item" DA.

    Then you must call this new DA from javascript like I've explained above.

    Sergio

  • devlarry
    devlarry Member Posts: 64 Blue Ribbon
    edited Oct 2, 2015 3:35PM

    Sergio,

    I did try that but it could not get the action to trigger. I even tried just doing an alert to see if the DA would trigger and no luck. I have tried custom event, jquery selector and several other options but none worked. I have no problems doing it if I am on the same page. It is only when I am in the pop up that I cannot get it to fire on the parent. I'll keep looking at it. Thanks for the help.

    Lawrence

This discussion has been closed.