Commit Graph
56 Commits
Author SHA1 Message Date
Behind The Math 29d7b4c664 Don't send an <option> tag if it's disabled, even if it's selected 2018-05-29 22:24:31 -04:00
Behind The Math 5885d76f37 Fix a bug where the value of <option> would not get sent if falsy
According to the spec, the value attribute should be sent if it
exists, even if it's falsy.
2018-05-29 22:24:31 -04:00
BehindTheMath e49d8947f7 Add the option to use FormData to encode the form elements (#153)
* Add the option to use FormData to encode the form elements

If the form's enctype attribute is set to "multipart/form-data",
use FormData to encode the form's elements.
2018-04-29 15:05:22 -04:00
BehindTheMath 7d26a75fdf Use the same options object in handle-response as in send-request (#148)
Instead of cloning this.options again in handle-response.js, pass the options object from send-request.js. This way, pjax.state.options will also have the request options.
2018-04-26 09:27:50 -04:00
Robin North 358b6f6836 Support multiple select fields in form submissions 2018-04-12 18:03:28 -04:00
BehindTheMath d6bf21ed22 Fix bugs and add tests (#145)
* Fix bug when checking if elements were parsed already

parse-element.js checks if the element was already parsed by
checking for the `data-pjax-click-state` attribute. However, this
attribute was not added until the link is clicked.

Originally, there was a separate attribute, `data-pjax-enabled`,
which tracked if the element was parsed already, but that was
changed in 9a86044.

This commit merges the attributes for mouse clicks and key presses
into one and adds that attribute when the element is initially
parsed.

* More bug fixes

* Fix documentation for currentUrlFullReload

* Ignore lines from coverage if they can't be tested

* Refactor attach-link and attach-form

* Fix and refactors tests

* Add tests

* Add TS definitions for options.requestOptions

* Code cleanup
2018-04-09 23:36:32 -04:00
Behind The Math 17d8262025 Add X-PJAX-Selectors header 2018-04-09 23:28:46 -04:00
BehindTheMath 75eb83dbc2 Add replaceNode switch (#141)
* Add replaceNode switch

* Add test for replaceNode()

* Update TS definitions
2018-03-20 10:52:55 -04:00
BehindTheMath 2166866967 Handle XHR response error (#137)
* Move the XHR callback to a separate file
* Trigger an error event if the response cannot be parsed.
* Add tests for handle-response.js
2018-03-15 16:12:32 -04:00
Robin North 05fa833169 loadUrl enhancements (#134)
`loadUrl` enhancements

- Make `options` parameter optional
- Allow partial overriding of instance options when calling `loadUrl` directly
- Make `requestOptions` optional
- Document `loadUrl` usage and provide examples
2018-03-06 10:06:38 +00:00
Robin North 07baae8e4d Fix form submission (#129)
* Fix check for radio and checkbox inputs

* Fix GET form submission

* Add example forms for testing

* Refactor query string building
2018-03-02 20:25:08 +00:00
BehindTheMath a72880d205 Code cleanup (#120)
* Lots of code cleanup

* Cleanup parse-options tests
  - Rename objects for clarity and inline unneeded objects
  - Remove unneeded tests
  - Use Object.keys().length instead of a custom function
  - Use typeof === "object" instead of a custom function that checks the prototype tree as well, since we don't expect anything but an object literal.

* Remove old switchFallback code

* Remove polyfill for Function.prototype.bind

* Inline small functions

* Add more documentation and tests for options.currentUrlFullReload
  Closes #17

* Update package.json
2018-02-02 09:52:44 -05:00
BehindTheMath 57aed828ac Merge pull request #118 from MoOx/fix/external-scripts-events
Fix external scripts events
2018-01-31 16:46:28 -05:00
Robin North 20e987929e Merge pull request #116 from MoOx/fix/blur
Fix element blurring (removing focus). Closes #4.
2018-01-29 20:03:24 +00:00
Robin North 05163d9fb5 Stop dispatching extraneous pjax:complete events, correct typo 2018-01-26 15:53:07 +00:00
Robin North a15c94c55a Merge pull request #113 from MoOx/cleanup/analytics
Cleanup default analytics function
2018-01-25 07:50:59 +00:00
Behind The Math fa05e94f07 Only blur element if it's contained by one of the selectors
Previously, Pjax would blur (remove focus) from the active element
regardless of where it was on the page. This restricts that to
happen only if the active element is contained by one of the
elements represented by options.selectors, because only those are
affected by Pjax.

Fixes #4
2018-01-24 20:18:41 -05:00
BehindTheMath e3df2b1c3d Merge pull request #114 from MoOx/fix/abort-pending-xhr
Abort previous pending XHR when navigating
2018-01-24 18:54:33 -05:00
Robin North 01fb72ceeb Simplify options assignment 2018-01-24 23:40:05 +00:00
Robin North f642eec047 Preserve ability to disable analytics behavior, explicitly document this option 2018-01-24 23:38:34 +00:00
Robin North cc384b9b16 Improve check for analytics function option 2018-01-24 23:35:45 +00:00
Robin North f559ca2914 Cleanup default analytics function 2018-01-24 23:35:45 +00:00
Robin North f7f68b2e50 Fix module filename 2018-01-24 23:15:40 +00:00
BehindTheMath 8fcef04c9e Merge pull request #112 from timtrinidad/master
Use a local clone of options when initiating requests, so requestOptions don't persist
2018-01-23 15:44:26 -05:00
Tim Trinidad 526a0883a2 Clone options in attach-link to prevent requestOptions changes from persisting 2018-01-23 13:22:31 -05:00
Robin North 486ef0e0ba Abort previous pending XHR when navigating 2018-01-23 15:25:56 +00:00
Behind The Math e7935d9c74 Add scrollRestoration option 2018-01-22 18:56:22 -05:00
Tim Trinidad e4b3952589 Clone options before modifying it for form submissions 2018-01-22 18:32:28 -05:00
BehindTheMath b5c2120d08 Fix async switches (#110)
If any switches are async, the subsequent code will execute before the switches are finished. This PR moves all that code to a new function, and debounces the calls to onSwitch() so it only executes
once, after all the switches finish.

Fizes #72.
2018-01-22 10:55:29 -05:00
Robin North cd09cc88d1 Replace instances of ES6 const keyword with var 2018-01-18 16:00:24 -05:00
Robin North b98e3ef914 Fix DOMException in switchElementsAlt()
Clone attribute nodes before setting on `oldEl` to prevent the following error:

```
DOMException: Failed to execute 'setNamedItem' on 'NamedNodeMap': The node provided is an attribute node that is already an attribute of another Element; attribute nodes must be explicitly cloned.
```
2018-01-17 17:07:02 -05:00
BehindTheMath 6fa51e58f8 Add checks for XHR redirects (#101)
Fixes #7

This checks for redirects by looking for the following, in sequence:
- XMLHttpRequest.responseURL
- the X-PJAX-URL header (like jquery-pjax)
- the X-XHR-Redirected-To header (like Turbolinks)
2018-01-10 15:45:55 -05:00
Behind The Math c0d64e41b8 Fix linting errors 2018-01-09 14:09:40 -05:00
BehindTheMath 6491e32437 Add an option to set a timeout for XHR requests (#95)
Closes #24.
2018-01-07 23:56:11 -05:00
Behind The Math d3d5ef7a11 Pass the element that triggered Pjax to the pjax:send event
Closes #62.
2017-12-21 13:06:49 -05:00
Behind The Math 0781f820ee Add switchElementsAlt() to the default switches
Fixes #83.
2017-12-19 15:56:48 -05:00
Bradley B Smith 1e40a0d70b Send the X-PJAX header with request (#80)
Make it more compatible with the jQuery PJAX and lets the server choose to optimize the response. Sending the list of selectors would be nice, too.
2017-12-19 13:56:30 +01:00
markusfluer 09f14fc86c Added evaluation of remote script tags 2017-11-02 12:51:36 +01:00
markusfluer 86e5a2281a Added support do do a push-state ajax request with forms 2017-09-18 14:13:45 +02:00
Maxime Thirouin eff7cfd452 Merge pull request #67 from compressed/refresh
Update refresh and handle attributes without values
2016-06-28 07:17:43 +02:00
Bart Nagel 7976f06043 Added: cacheBust option (#71)
* Refactor request test to allow further tests to be added

* Make cache-busting optional

Closes #70
2016-06-28 06:46:14 +02:00
Christopher Brickley beaa21fb3a fix(refresh): use this.parseDOM for refresh
Fix for issue mentioned in #36
2016-04-19 12:13:14 -04:00
Maxime Thirouin afe0ddb6b9 Fixed: `this.reload` is now a Function
Closes #65
2016-03-24 12:38:15 +01:00
COoL e3d0f8cc1b fixed an error when using pjax with google analytics 2016-01-15 17:32:07 +08:00
Maxime Thirouin 546b7e309a Merge pull request #50 from darylteo/patch-5
Patch 5
2016-01-05 07:14:29 +01:00
darylteo 97c8b2d749 [NEW] #5 Ignore default prevented clicks 2016-01-04 23:19:36 +11:00
darylteo 1d292a1a6e [FIX] #39 - events on top level
Events triggered on top level elements (such as window or document)
lead to a HierarchyRequestError due to a fix in IE browsers
where dispatchEvent does not fire if an element is not in the DOM.

The current test is simply to check for the existence of parentNode
However, this means top level elements get added to itself, causing
the error.

The proposed fix simply tests for top level elements in the test.
2016-01-04 22:30:00 +11:00
Maxime Thirouin af8783587c refresh now accept an argument so you can refresh just a part of a page 2015-01-29 07:33:13 +01:00
Peter Lada 9a86044f90 changed existing refresh method to reload. changed the data check to trigger a refresh on the element based on the already bound data attr 2015-01-28 18:27:16 -08:00
Peter Lada e6a35f38e4 attach data to pjaxified links so they can't be pjaxified twice. add simple refresh method 2015-01-21 00:11:59 -08:00