Closed pellucide closed 12 years ago
hey @pellucide thanks for posting the issue, I will add some tests and try to figure out why it isn't working. (we run our tests against the 3 latest major release of mootools).
hi @pellucide I have fixed this issue in the dev branch with c1a033d
let me know if you have any other issues. thanks!
That was unexpectedly quick. Thanks a lot
I was going through the fix. I am a newbie with javascript. what does the ":relay(" + selector + ")" do ? Its in the file simpleCart.js
Ah, yes. I actually had to look this one up (I am much better with jQuery). Basically, you can delegate event listeners to a containing element.
So lets say I have a table with a 100 rows that I am removing and adding, and I want to know when a row is clicked, it would be crazy to attach an event listener to every row added and then remember to remove it.
Instead, I can attach an event to the table and say "tell me whenever a row inside of you gets clicked," because the event will "bubble up" the DOM. This way, I can tell when any row is clicked with a single listener. The code would look like this:
document.id( "myTable" ).addEvent( 'click:relay(tr)' , function( e ) {
console.log( "A table row was clicked!");
));
The "click:relay( selector )" tells mootools to watch for a click event on any of its children that match the selector.
I use this method with simpleCart(js) so that I don't have to attach and remove click events to elements every time the page is updated. I just add the listener to the body, and you can change the entire DOM without simpleCart(js) knowing, and it will still "catch" the click events. This method of using the body or document as the delegate is similar to jQuery's .live() method.
This is pretty sweet. Thanks. I am starting to like java-script more than java. Its a very powerful language.
Thanks for the awesome simpleCart. I have been trying to integrate simpleCart to enable online ordering. The issue I am facing is selectors don't work with mootools-core-1.4.5. They work nicely with jQuery. I could change to jQuery, but that entails a lot of work that has been already done with MooTools. Also I like mootools style of javascript coding . Here is a simple piece of code that shows the problem. In this code the selectors are
.simpleCart_increment .simpleCart_decrement .simpleCart_shelfItem .add_item
I would appreciate some help on this Thanks