quirkey / sammy

Sammy is a tiny javascript framework built on top of jQuery, It's RESTful Evented Javascript.
http://sammyjs.org
MIT License
2.99k stars 384 forks source link

Href click event not propagation after click #244

Open tn801534 opened 9 years ago

tn801534 commented 9 years ago

=>I think "return true;" if better so the click event can delegate to parents.

$(document).delegate('a', 'click.history-' + this.app.eventNamespace(), function (e) { if (e.isDefaultPrevented() || e.metaKey || e.ctrlKey) { return; } var full_path = lp.fullPath(this), // Get anchor's host name in a cross browser compatible way. // IE looses hostname property when setting href in JS // with a relative URL, e.g. a.setAttribute('href',"/whatever"). // Circumvent this problem by creating a new link with given URL and // querying that for a hostname. hostname = this.hostname ? this.hostname : function (a) { var l = document.createElement("a"); l.href = a.href; return l.hostname; }(this);

      if (hostname == window.location.hostname &&
          app.lookupRoute('get', full_path) &&
          Sammy.targetIsThisWindow(e, 'a')) {
        e.preventDefault();
        proxy.setLocation(full_path);
        return false;                                                      
      }
    });
mdumouchel commented 9 years ago

Is there a reason that it is set to false? I also agree it seems strange for it preventing a links from delegating.