xui quick quesiont

2 views
Skip to first unread message

Air YT

unread,
Sep 3, 2010, 9:47:41 AM9/3/10
to xui-js
howdy - stumbled upon this while looking for some nice lightweight js
frameworks for our site. i can appreciate the lack of detailed
documentation, but i can't seem to find a decent forum for discussions/
problems so i hope this finds someone!

quick question - in the on event callback, how is it possible to
reference the element in question. for example, i want to do this:



function load_page( url, element_id ) {
x$( "#" + element_id ).xhr( url );
}
x$(window).load(function(e){
x$('a').click( function( f ){
load_page( [href attribute of the a tag], 'content' );
});
});

essentially that creates an ajaxian way of loading content into the
div id content by binding the load_page function to all the a tags.
BUT! i can;t figure out how to reference the a tag's href attribute in
the load_page call.

any help would be appreciated and thanks for the great work! cheers,
graham

Brian LeRoux

unread,
Sep 3, 2010, 4:53:13 PM9/3/10
to xui-js
This really has very little to do with XUI. Time to bone up on
JavaScript DOM events! In any case.. this should help ya get goin:

x$('a').click(function(e) {
console.log(e.target);
console.log(x$(this));
// etc
});

Air YT

unread,
Sep 9, 2010, 12:01:38 PM9/9/10
to xui-js
Brian - thanks for the quick reply. so here's what i've got. i
certainly don't expect you to fix this for me, but off the top of yer
head, any ideas would be welcome:

<script src="/js/xui.bb.js" type="text/javascript"
charset="utf-8"></script>
<script type="text/javascript">
x$(window).load(function(e){
init_links();
});
function init_links(){
x$('a').click(function(e) {
load_page( e.srcElement.href );
return false; // stops browser from actually browsing
to the new page
});
}
function load_page( url ) {
// alert( 'loading: ' + url ); // debug
x$( "#content" ).xhr( url ).addClass( "current" );
init_links();
}
</script>

essentially what i'm trying to do is to easily take a large mobile
project, and make all a tags load ajaxian-style into a div with
id=content. lots of reasons why we're doing it this way, but in order
to save ourselves some time, i was hoping the above would work - ie
binding an ajax load function to the a tag's click event. it seems to
react nicely in webkit, but not the BlackBerry browser it's designed
for (nor FFX or IE)

any ideas on binding all a tags to a ajax-load-to-div using xui would
be incredibly helpful.

THANKS again, graham

Brian LeRoux

unread,
Sep 10, 2010, 8:26:40 PM9/10/10
to xui...@googlegroups.com
hey buddy, I think it might be due to blackberry .... which one are
you testing against?

> --
> You received this message because you are subscribed to the Google Groups "xui-js" group.
> To post to this group, send email to xui...@googlegroups.com.
> To unsubscribe from this group, send email to xui-js+un...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/xui-js?hl=en.
>
>

Reply all
Reply to author
Forward
0 new messages