24 ways to impress your friends

Jump to menu

Vote up?

Jeremy Keith

David Goss wrote: “Only thing I’d add would be to hijax the link to trigger searchNews when clicked rather than taking you off-page.”

Excellent idea! You’d still only need to write the Ajax code once, but you’d simply change the event that triggers it based on viewport size:

On a large viewport, trigger the Ajax request once the page has loaded.

On a smaller viewport, trigger the Ajax request when the link is clicked.

I like it!