2018-04-09 17:39:20 -04:00
|
|
|
var attrState = "data-pjax-state"
|
|
|
|
|
|
2014-05-06 08:19:23 +02:00
|
|
|
module.exports = function(el) {
|
|
|
|
|
switch (el.tagName.toLowerCase()) {
|
2018-01-09 00:44:20 -05:00
|
|
|
case "a":
|
|
|
|
|
// only attach link if el does not already have link attached
|
2018-04-09 17:39:20 -04:00
|
|
|
if (!el.hasAttribute(attrState)) {
|
2018-01-09 00:44:20 -05:00
|
|
|
this.attachLink(el)
|
|
|
|
|
}
|
|
|
|
|
break
|
2014-05-06 08:19:23 +02:00
|
|
|
|
2017-09-18 14:13:39 +02:00
|
|
|
case "form":
|
|
|
|
|
// only attach link if el does not already have link attached
|
2018-04-09 17:39:20 -04:00
|
|
|
if (!el.hasAttribute(attrState)) {
|
2017-09-18 14:13:39 +02:00
|
|
|
this.attachForm(el)
|
|
|
|
|
}
|
2018-01-09 00:44:20 -05:00
|
|
|
break
|
2014-05-06 08:19:23 +02:00
|
|
|
|
2018-01-09 00:44:20 -05:00
|
|
|
default:
|
|
|
|
|
throw "Pjax can only be applied on <a> or <form> submit"
|
2014-05-06 08:19:23 +02:00
|
|
|
}
|
|
|
|
|
}
|