iUI- target self automatically for all links in page?

9 views
Skip to first unread message

rmogull

unread,
Jul 2, 2009, 12:30:08 PM7/2/09
to iPhoneWebDev
Hi,

We're adding iPhone functionality to our site build on
expressionengine. We have many hundreds of posts with thousands of
internal links.

Is there any way using iUi to have all links on a given page open
externally without changing all our links? Basically, I'm hoping that
when I have a page load, rather than pulling in sub pages via AJAX,
any links on that page will target self (or maybe open a new window).
I'm hoping there's a way to do this other than having to add
target="_self" to all our links, since that's a heck of a search and
replace option.

If you go to http://securosis.com/iphone, then navigate to a post,
then click on any link, you will see what I mean.

Thanks

Sean Gilligan

unread,
Jul 2, 2009, 1:43:16 PM7/2/09
to iphone...@googlegroups.com
rmogull wrote:
> Hi,
>
> We're adding iPhone functionality to our site build on
> expressionengine. We have many hundreds of posts with thousands of
> internal links.
>
> Is there any way using iUi to have all links on a given page open
> externally without changing all our links?

There's always a way ;)

> Basically, I'm hoping that
> when I have a page load, rather than pulling in sub pages via AJAX,
> any links on that page will target self (or maybe open a new window).
> I'm hoping there's a way to do this other than having to add
> target="_self" to all our links, since that's a heck of a search and
> replace option.
>

You should be able to make a fairly minor modification to iui.js that
will disable the "auto-ajax" feature of iUI for certain 'pages' (i.e.
nodes in your DOM) Look at the click event listener (code block that
starts 'with addEventListener("click",') One approach would be to
modify your iUI-specific templates to use target="_ajax" when you want
to do an ajax load and revert to the browser-defined default behavior
(i.e. loading a new page) when there is no target. Another approach
might be to use partial URLs for ajax links and full URLs for page
loads. It depends on the exact structure of your DOM and the data and
which pages are easy to modify and which aren't.

I also highly recommend giving each 'page' (aka <div>) a unique ID in
your templates if at all possible. It will cut down memory usage in
the DOM.

-- Sean


rmogull

unread,
Jul 2, 2009, 6:44:04 PM7/2/09
to iPhoneWebDev
Great idea- that should easily solve it!

Off to code...
Reply all
Reply to author
Forward
0 new messages