Add simple refresh method and protect against links being bound more than once. #36

Merged
pklada merged 2 commits from refresh into master 2015-01-29 01:03:16 -05:00
4 changed files with 14 additions and 1 deletions
Showing only changes of commit e6a35f38e4 - Show all commits

View File

@@ -44,6 +44,8 @@ Pjax.prototype = {
parseDOM: require("./lib/proto/parse-dom.js"),
refresh: require("./lib/proto/refresh.js"),
attachLink: require("./lib/proto/attach-link.js"),
forEachSelectors: function(cb, context, DOMcontext) {

View File

@@ -56,6 +56,8 @@ var linkAction = function(el, event) {
module.exports = function(el) {
var that = this
el.setAttribute("data-pjax-enabled", "true");
on(el, "click", function(event) {
linkAction.call(that, el, event)
})

View File

@@ -1,7 +1,10 @@
module.exports = function(el) {
switch (el.tagName.toLowerCase()) {
case "a":
this.attachLink(el)
// only attach link if el does not already have link attached
if (!el.getAttribute("data-pjax-enabled")) {
this.attachLink(el)
}
break
case "form":

6
lib/proto/refresh.js Normal file
View File

@@ -0,0 +1,6 @@
var parseDom = require("./parse-dom")
module.exports = function(el) {
parseDom(document);
}