News for hackers. Stuff that matters.
Re:This Week in Rails: jQuery no longer part of Rails, and more by TekMol on Friday December 09, 2016 @11:42AM (#13139776)
Not completely sure what you mean. Could you make a minimal example on jsfiddle? Then I can make the vanilla counterpart and we can compare.
Re:This Week in Rails: jQuery no longer part of Rails, and more by mercer on Saturday December 10, 2016 @02:38AM (#13144583)
Sorry, no time right now for that. I'll try to explain more clearly. There's no problem if I can bind directly to the element. However, that's often not possible. Imagine a <Carousel> element that is initialized, event listeners and all, but only receives data (<Item> elements) at a later time.

In jQuery I can do something like this:

    $(<Carousel>).on('click', <Item>, function(e) {
        // using this 'this' gives you the <Item> element. Always. Even 
        // if you click on a child element of <Item>. And it works if 
        // you add or remove items. Also it doesn't add a listener 
        // to *every* single item, which matters if you've got a whole 
        // bunch of them!
    });
The vanilla equivalent is often presented to be as simple as:

    <Carousel>.addEventListener('click', function(e) {
        // e.target is the actual element you clicked. So now we need to 
        // figure out if this element is inside an <Item>, and perhaps 
        // also *which* <Item>. There's various approaches, and it's 
        // not rocket science, but it's all extra work for something that 
        // seems like a common scenario.
    });
Re:This Week in Rails: jQuery no longer part of Rails, and more by TekMol on Sunday December 11, 2016 @01:16PM (#13152258)
I still think we should discuss it via a real fiddle we can test the approaches with. Talking about pseudecode with placeholders is much more nebulus then talking about real code.
Re:This Week in Rails: jQuery no longer part of Rails, and more by mercer on Monday December 12, 2016 @04:10AM (#13156728)