On Aug 11, 5:42 am, rmb177 <[email protected]> wrote:
> I am developing an ASP.net web app using iui for the front end
> (targeted for the iPhone). I have a main page in which I've added a
> second "navBar" underneath the standard iui navBar. I use this second
> bar as a toolbar that has some buttons to allow the user to toggle
> between different views of the main page. When the user taps one of
> the buttons, I am making an AJAX call to the server to update the main
> view. The buttons on the tool bar need updating so I've added some
> custom target="_replace" code so I can replace out a specific item
> within the page, in this case the <body> element.
>
> I'm fairly certain I'm returning the correct html from my ASP.net.
> Tapping one of these buttons results in a page as I'm expecting. I've
> added the javascript function below to replace out the body of my page
> (all of the buttons have target="bodyReplace" and my body has
> id="bodyReplace":
>
> <code>
> function replaceElementDirectly(source, targElem) {
>       var target = document.getElementById(targElem);
>       var targetParent = target.parentNode;
>       var frag = document.createElement(target.localName);
>       frag.id = targElem;
>       frag.innerHTML = source;
>       targetParent.removeChild(target);
>       targetParent.appendChild(frag);
>    }
> </code>

That seems inefficient. If you're using innerHTML, why not:

 function replaceElementDirectly(source, targElem) {
   document.getElementById(targElem).innerHTML = source;
 }

At the very least, the last two lines could be:

  targetParent.replaceChild(frag, target);


--
Rob

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"iPhoneWebDev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/iphonewebdev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to