Skip to content
This repository has been archived by the owner on Oct 11, 2019. It is now read-only.

Add xhr object to callbacks. Add additional header X-Wiselinks-Target. #94

Open
wants to merge 20 commits into
base: master
Choose a base branch
from

Conversation

phlegx
Copy link

@phlegx phlegx commented Dec 18, 2014

Add xhr object to callbacks

To handle headers in Wiselinks callbacks (javascript events) I have added xhr in callbacks for page:fail, page:redirected, page:done. The xhr in the callbacks can be very useful.

Example

$(document).off('page:done').on('page:done', function(event, $target, status, url, data, xhr) {
  message = xhr.getResponseHeader('X-Flash-Message');
  type = xhr.getResponseHeader('X-Flash-Message-Type');
});

Javascript Events

  1. page:done ($target, status, url, data, xhr)
  2. page:fail ($target, status, url, error, code, xhr)
  3. page:redirected ($target, render, url, xhr)

Add additional header X-Wiselinks-Target

The target, if used in the link or form, gets included in the header data and can be retrieved with request.wiselinks_target in the controller.

Add additional header X-Wiselinks-Scope

The scope, if used in the link or form (data-scope=), gets included in the header data and can be retrieved with request.wiselinks_scope in the controller.

@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling 080972b on phlegx:master into 19b88b1 on igor-alexandrov:master.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants