DomAPI Home
DomAPI
Build: 4.0 BETA
Topic: add elm to parent from ajax result function

  DeanL registered v4 wrote on Tuesday 11/29/05 at 3:11 PM (PST)  
 

On a dynamically created popup form, I have an asyncronous ajax call working and returning an id inside the form's onsubmit function...

onsubmit
...
domapi.ajax.request({
url : "doSomething.php?id = ' + uID + '&Subject=' + sub,
async : true,
onsuccess : addDisplayItem(req),
onerror: function(req) {alert("Error updating event.");}
});
...
// closes the form here


and the function...

function addDisplayItem(id){
// putting an alert here does show the returned id

// now I just want to add an elm in the top doc's hard coded container
// so the user can see the results of their actions
elm = domapi.Elm({ x:0, y:0, w:50, h:14, p:domapi.getElm("HardCodedAreaOnTopParent")});
elm.id = id;
elm.setB(1);
elm.style.borderColor="black";
elm.style.borderStyle="solid";
elm.style.fontFamily = "Verdana";
elm.style.fontSize = "xx-small";
elm.style.color = "black";
elm.style.position="relative";
elm.style.wordWrap="break-word";
elm.style.textAlign="left";
elm.style.padding="0 0 0 10px";
elm.setAlpha(75);
elm.setText("Test");

return elm;
}

This function doesn't do anything in ie, and gives me a couple of 'domapi not defined' errors. Is there some reason the scope inside addDisplayItem is special? I did also try 'parent.' in front of the domapi references, as well as trying to pass the parent as a parameter...Here is a function that directly follows the addDisplayItem that does seem to allow me to reference the form to close it...

function quickFormCancel(){
parent.quickform.remove(); // quickform is the dynamic form
return false;
}

Why can't I have this elm appear once my ajax function is successful in this case?

Thanks


 
    RSS feed of forum  
  Darin Kadrioski registered v4 wrote on Tuesday 11/29/05 at 9:56 PM (PST)  
 

DomAPI can only create elms within the page it was included on. It sounds like you are trying to use it in an unsupported manner.

 
    RSS feed of forum  
  DeanL registered v4 wrote on Wednesday 11/30/05 at 7:58 AM (PST)  
 

User clicks on main page link, new elm opens, user acts, elm closes, main page elm gets added....is this not a very common thing to do?

Maybe I'm looking at this from the wrong way. Do I need to utilize a main page event to create my resulting elm maybe...

 
    RSS feed of forum  
  DeanL registered v4 wrote on Wednesday 11/30/05 at 8:00 AM (PST)  
 

or skip the dynamic creation of these forms, and create them on the initial load and hide them? I did think of this way originally, but seems inefficient compared to doing things only when they are needed.

 
    RSS feed of forum  
  Darin Kadrioski registered v4 wrote on Wednesday 11/30/05 at 8:20 AM (PST)  
 

You're mixing terms like popup, topparent and elm making it difficult to tell what it is you are doing. If you do have two separate windows, each window must have its own copy of the library. If that's not what you are doing, then please be more specific.

tnx

 
    RSS feed of forum  
  DeanL registered v4 wrote on Wednesday 11/30/05 at 9:45 AM (PST)  
 

okay...
popup form - a dynamically create elm of iframe type with a src containing a basic html form

topparent, main page, top page - the html doc loaded by the user initially

elm - I will try and not use just elm


User clicks on main page link, new popup form opens, user clicks submit, popup form closes, main page gets a new icon (elm) added....everythings working but the last step.

If this doesn't make sense, I will just leave you alone...


 
    RSS feed of forum  
  Henry registered v4 wrote on Wednesday 11/30/05 at 1:14 PM (PST)  
 

iframe is in it's own window. it got it's own dom tree. that require it's own copy of domapi running. You can pass data between windows. but don't expect you can create some dom nodes and pass them around to insert in different dom tree.

To solve your problem, just pass the simple data back to the parent, and let the parent document create the elm.

Henry

 
    RSS feed of forum  
  DeanL registered v4 wrote on Wednesday 11/30/05 at 3:40 PM (PST)  
 

Sure, makes sense to me. Thanks Henry.

Started doing just that and...

myfunc is hard coded in the parent document.

I have tried parent.myfunc(), window.parent.myfunc(), window.opener.myfunc() but just get 'no properties' errors. While I have a line in the script above that that has parent.myvar.remove(), myvar being the variable referencing the popup form, which works....so confusing.

I'll keep at it, but if you see anything I'm missing...

 
    RSS feed of forum  
You could respond to this post if you were logged in.
DHTML by www.domapi.com