Permalink
Browse files

Added .editorconfig. Added persistence of Payload.apiRequest() method…

…'s optional data attribute as an Array if is defined as so, otherwise it will be merged to an object.
  • Loading branch information...
pklauzinski committed May 17, 2016
1 parent 33ea780 commit c8a32c8b12f7c41dfad99e49f25de60ee20f1aaf
Showing with 27 additions and 4 deletions.
  1. +7 −0 .editorconfig
  2. +14 −2 README.md
  3. +6 −2 payload.js
View
@@ -0,0 +1,7 @@
[*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = false
View
@@ -16,7 +16,8 @@ When DOM objects imbued with Payload.js's selectors are activated, a call to `Pa
- [Install from Bower](#install-from-bower)
- [Dependencies](#dependencies)
- [Selectors](#selectors)
- [Payload.js Options](#payloadjs-options)
- [HTML5 API](#html5-api)
- [Payload.js Initialization Options](#payloadjs-initialization-options)
- [Primary Methods](#primary-methods)
- [Helper Methods](#helper-methods)
- [API Request Handling](#api-request-handling)
@@ -63,7 +64,18 @@ Payload.js automatically binds to HTML elements based on the following selectors
Payload.js selectors can also contain the `data-auto-load` attribute to cause them to be automatically invoked on page/template load. Selectors are used to invoke API calls and/or render templates when they receive an appropriate user or trigger event.
## Payload.js Options
## HTML5 API
The most useful feature of Payload.js is its intuitive HTML5 API. It can be used out of the box with little to no configuration and interacted with entirely from HTML. This makes Payload.js accessible to the non javascript savvy web developer.
```html
<a href="/history-url"
data-url="/api/endpoint"
data-template="template-name"
data-selector=".dom-selector">My link text</a>
```
## Payload.js Initialization Options
| Option | Type | Default | Description |
|----------------------|----------------------|-------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
View
@@ -7,7 +7,7 @@
* http://www.opensource.org/licenses/mit-license.php
*
* @author Philip Klauzinski
* @version 0.4.1
* @version 0.4.2
* @requires jQuery v1.7+
* @preserve
*/
@@ -411,7 +411,11 @@
template: _options.templatesNamespace[$origin.attr(_dataPrefix + 'template')] || false,
partial: _options.partialsNamespace[$origin.attr(_dataPrefix + 'partial')] || false,
events: $origin.attr(_dataPrefix + 'publish') ? $origin.attr(_dataPrefix + 'publish').split(' ') : [],
requestData: $.extend({}, _this.serializeObject($origin), data || {}, JSON.parse($origin.attr(_dataPrefix + 'form') || '{}')),
requestData: $.extend(
data !== undefined && data.constructor === Array ? [] : {},
_this.serializeObject($origin), data || {},
JSON.parse($origin.attr(_dataPrefix + 'form') || '{}')
),
timeout: $origin.attr(_dataPrefix + 'timeout') || _options.timeout,
templateData: {
app: _this.appData,

0 comments on commit c8a32c8

Please sign in to comment.