Thanks for the collaboration Sergio, helped a lot to the unfolding of the issue, but I had to make some adaptations, because the list of objects is a little more complex than a string, for example..
The resolution was as follows::
I thought of using Postmessage, but for that I would need the modal iframe to be open, first step then create the modal.
In the newly created modal, it returns to the previous iframe, and collects the object. We call the function getaway() on onload.
function getItem() {
try {
var returnToUrl = "FCADQUAL.aspx";
var msgAddr = window.location.protocol + "//" + window.location.host + returnToUrl;
var o = parent.document.getElementById("ifr_FCADQUAL");
o.contentWindow.postMessage("100;0", msgAddr);
} catch (e) {
Save Exception();
}
}
In the previous iframe then, you receive the post merge, and add the object to the parameter, and send it back:
window.addEventListener("message", receiveMessage, false);
function receiveMessage(e) {
try {
//url que verifica se post message é valido
var url = window.location.protocol + "//" + window.location.host
//testa se origem do post é do mesmo dominio
if (e.origin !== url)
return;
var sData = e.data.split(";")
//Solicita informações do item para a tela de informações diversas
sendInfoDiver();
} catch (e) {
Save Exception();
}
}
function sendInfoDiver() {
try {
var returnToUrl = "FCADELEM.aspx";
var msgAddr = window.location.protocol + "//" + window.location.host + returnToUrl;
var o = parent.document.getElementById("ifr_FCADELEM");
o.contentWindow.postMessage(elementsList, msgAddr);
} catch (e) {
Save Exception();
}
}
Then, already in the modal screen that recem was opened, receives the object and starts the treatment.
window.addEventListener("message", receiveMessage, false);
function receiveMessage(e) {
try {
//url que verifica se post message é valido
var url = window.location.protocol + "//" + window.location.host
//testa se origem do post é do mesmo dominio
if (e.origin !== url)
return;
if (typeof e.data == "object") {
//Recebe o objeto item e popula campos do formulário
setData(e.data);
}
//Oculta a mensagem de loading
parent.hideLoading();
} catch (e) {
Save Exception();
}
}
function setData(PlReturn) {
...
}
And to send the updated data back, just do the reverse path.
I appreciate the collaboration, and remains the source of research for future community doubts.
Hug
I don’t understand your problem. Can you explain better? The array and the object are in different files/pages? at different times?
– Sergio
And basically, I open a modal window by clicking a button, Parent.createDialog(oElem); creates the modal, and I need this list within the modal JS, which I should open.
– William de Castro
Your modal is an iframe? if not, then everything is available. You may have to adjust the scope, but it seems simple to solve. Another question. What is the relationship between the two? For example, the 1st el of the array has to do with which part of the object?
– Sergio
The window where the data comes from is also an iframe, it is not possible to store on the parent page. So, theoretically, it’s like it’s from one page to another.
– William de Castro
Ok, and iframe is on the same domain? and by the way, use some library like jQuery or Mootools?
– Sergio
William, with the details missing from the question it will be possible to answer with the solution. You can add this information to the question also to make it more complete.
– Sergio
Yes, in the same domain, use jQuery.
– William de Castro
William, I put an answer. I don’t know which modal you use, if it’s not the jQuery UI say which one I can adjust the answer to.
– Sergio