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!

Setting value of select list after triggering refresh using jQuery

Arijit KanrarDec 16 2014 — edited Dec 17 2014

Hello everyone,

I've got an Application Express 4.1.1.00.23 application running on a Oracle 10g R2 database.

In the application I have a page (let's assume it to be Page 10) which has a drop down (let's call it P10_PARENT). Next to the drop down I have a button which when clicked opens up another popup window with page 11. This page 11 is used to create more of the items listed by the P10_PARENT drop down. When we enter the data in P11 and click on OK we have a javascript calling an application process which creates the object in the database. Now the P10_PARENT select list has to be updated to reflect this new object. So after the application process is run, the javascript on Page 11 calls a function in Page 10 using window.opener.functionName. This function in Page 10 performs an apex refresh using

$('#P10_PARENT').trigger('apexrefresh');

After this function returns back to Page 11, the page is closed using window.close().

It works fine up till this point. Now we also have to default the selected value in the select list to the newly created object. We have made a function for that. But calling it immediately after triggering the apex refresh doesn't work because it probably has not updated the list from the back-end yet.

So we are binding an apexafterrefresh event to this element and performing the defaulting here. Like this:

$('#P10_PARENT').bind('apexafterrefresh',function(){

  setdefault('P10_PARENT',newCreatedObjVal);

  alert('Refresh completed!');

});

But this event seems not being triggered. I've tested both in IE and Chrome. In Chrome it triggered once but never after that.

The pertinent code in page 10 looks like this. The function refreshBusList is called from Page 11 with the value of the newly created object.

function refreshBusList(pDefault)

{

  newCreatedObjVal = pDefault;

   $('#P10_PARENT').trigger('apexrefresh');

}

$('#P10_PARENT').bind('apexafterrefresh',function(){

  setdefault('P10_PARENT',newCreatedObjVal);

  alert('Refresh completed!');

});

I'd like to know what we're doing wrong. Is this even the right way to do this? I cannot use dynamic actions here because the page javascript logic is too complicated to be properly implemented using declarative logic like DAs (we tried once and had to give up after a week. became a nightmare to manage it).

Any help would be highly appreciated!

Thanks!!

Arijit

This post has been answered by Tom Petrus on Dec 16 2014
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 14 2015
Added on Dec 16 2014
2 comments
1,217 views