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
pklada commented 2015-01-21 18:12:20 -05:00 (Migrated from github.com)

This will add a basic .refresh method which can be called by the user to refresh links on their page to be pjaxified.

It also adds a data attr to links when they are pjaxified so that they can't be double-bound.

This will add a basic `.refresh` method which can be called by the user to refresh links on their page to be pjaxified. It also adds a data attr to links when they are pjaxified so that they can't be double-bound.
pklada commented 2015-01-28 21:28:15 -05:00 (Migrated from github.com)

@MoOx thanks for checking this out. I made some updates based on your comments. I actually do think it makes more sense for this to be called refresh, and the existing method to be called reload (as it does reload the page). Let me know what you think.

@MoOx thanks for checking this out. I made some updates based on your comments. I actually do think it makes more sense for this to be called refresh, and the existing method to be called reload (as it does reload the page). Let me know what you think.
MoOx commented 2015-01-29 01:03:14 -05:00 (Migrated from github.com)

It's better than nothing.
Good work. Thanks !
Tests are broken but it seems related to a tiny thing, so I'm merging.
I'll update some tiny stuff and prepare CHANGELOG for a future release.

It's better than nothing. Good work. Thanks ! Tests are broken but it seems related to a tiny thing, so I'm merging. I'll update some tiny stuff and prepare CHANGELOG for a future release.
pklada commented 2015-01-29 12:40:43 -05:00 (Migrated from github.com)

Thanks!

Thanks!
robinnorth commented 2016-04-12 08:45:54 -05:00 (Migrated from github.com)

@MoOx @pklada I'm currently building something using PJAX that requires me to use the helpful new refresh method. However, the existing implementation doesn't currently work, as refresh uses parseDom which in turn calls this.getElements... which is undefined as this is assigned to the global scope.

A simple fix I have tested is to reference the current PJAX instance's parseDOM method instead:

module.exports = function(el) {
  this.parseDOM(el || document)
}

If you like, I can submit a new PR with this change.

@MoOx @pklada I'm currently building something using PJAX that requires me to use the helpful new `refresh` method. However, the existing implementation doesn't currently work, as `refresh` uses `parseDom` which in turn calls `this.getElements`... which is undefined as `this` is assigned to the global scope. A simple fix I have tested is to reference the current PJAX instance's `parseDOM` method instead: ``` js module.exports = function(el) { this.parseDOM(el || document) } ``` If you like, I can submit a new PR with this change.
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: iLoveElysia/pjax#36