jmpressjs / jmpress.js

A jQuery plugin to build a website on the infinite canvas
http://jmpressjs.github.com/jmpress.js
1.5k stars 237 forks source link

jQuery data-delegate attribute problem #101

Closed dark2y closed 11 years ago

dark2y commented 11 years ago

Frist of all great plugin, i used it to make a full website.

I had some problems with the delegate attribute ( the first selector was always "true" ) so i modified your code a bit so that it would work. I wanted to post the fix here so you could merge it . Also it would be a great idea if you would let the "apply" template function to work with functions not just array's and strings.

Great code man :+1:

/* modified line 339 */

delegated = checkObjectDelegate($(el).parentsUntil(jmpress).filter(settings.stepSelector).filter(step.delegate)) ||
                    checkObjectDelegate($(el).near(step.delegate)) ||
                    checkObjectDelegate($(el).near(step.delegate, true)) ||
                    checkObjectDelegate($(step.delegate, jmpress));

/* added line 346 */

function checkObjectDelegate(delegated){
    if(delegated.length != 0) return delegated;
    return false;
}
sokra commented 11 years ago

you are right... the old code wrongly asumes that an empty jquery object evaluates to false.