event binding

32 views
Skip to first unread message

naimon

unread,
Oct 19, 2010, 8:03:58 AM10/19/10
to xui-js
hello again everybody. I'm really exhausted last 2 days. now I have a
problem with event binding
I m getting this error
Uncaught TypeError: Cannot read property '2' of undefined

x$('#play-pause').on('click', function(){ alert('Clicked!'); });

by the way I m getting undefined method error when I use click method
instead of "on"

#play-pause element is a DIV.

I'm using xui-core-1.0.0.min.js from xuijs.com and running on Chrome.

Thanks

Brian LeRoux

unread,
Oct 19, 2010, 2:29:20 PM10/19/10
to xui...@googlegroups.com
yeah I think that build is bad. I need to update it... pls use the
github.com/xui/xui src

Brian LeRoux, Nitobi Software
---
Office: +1 (604) 685-9287
Toll-Free (North America Only): 1-866-632-2777
Cell: +1 (604) 868-1978
http://blogs.nitobi.com/brian
http://www.nitobi.com
http://twitter.com/brianleroux

> --
> 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.
>
>

naimon

unread,
Oct 21, 2010, 8:07:33 PM10/21/10
to xui-js
hello brian,

I was really busy with my regular job yesterday and I couldnt find any
chance to take a look my project. but today finally I built github/xui
version without any error. it works really great now. but something
strange happened in my tests.
let's say I create many div(absolute) elements and add them into body
as innerHTML.
When I create a div I apply some modifications before adding another
one.

* Top, Left, Width, Height

After these style modifications I apply this event binding:

$('my-div').on('click', function(e){alert(e.target.id);});

After this event binding my loop jumps to next and creates another
div. etc.

I add 100 elements in that routine. But click event works for last one
only!

Is there any callback feature for x$().html method? I think I try to
apply event binding before I create the element.

Source code of my routine:

parent = x$(document.getElementsByTagName('body'));
parent.html('inner', parent.html() + '<div id="' + id + '"></div>');
x$('#' + id).addClass(cls)
.css({
position: 'absolute',
top: top,
left: left,
'border-radius': round,
width: width,
height: height
});
x$('#' + id).on('click', handler);



By the way, if I bind event to my elements after all of them created
there is no problem. click event works for each of them. what do you
think?

-Umut

On Oct 19, 9:29 pm, Brian LeRoux <brian.ler...@nitobi.com> wrote:
> yeah I think that build is bad. I need to update it... pls use the
> github.com/xui/xui src
>
> Brian LeRoux, Nitobi Software
> ---
> Office: +1 (604) 685-9287
> Toll-Free (North America Only): 1-866-632-2777
> Cell: +1 (604) 868-1978http://blogs.nitobi.com/brianhttp://www.nitobi.comhttp://twitter.com/brianleroux
Reply all
Reply to author
Forward
0 new messages