pjax_rails 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- data/vendor/assets/javascripts/jquery.pjax.js +44 -10
- metadata +2 -2
@@ -44,10 +44,10 @@ function fnPjax(container, options) {
|
|
44
44
|
//
|
45
45
|
// $(document).on('click', 'a', function(event) {
|
46
46
|
// var container = $(this).closest('[data-pjax-container]')
|
47
|
-
//
|
47
|
+
// $.pjax.click(event, container)
|
48
48
|
// })
|
49
49
|
//
|
50
|
-
// Returns
|
50
|
+
// Returns nothing.
|
51
51
|
function handleClick(event, container, options) {
|
52
52
|
options = optionsFor(container, options)
|
53
53
|
|
@@ -87,6 +87,44 @@ function handleClick(event, container, options) {
|
|
87
87
|
event.preventDefault()
|
88
88
|
}
|
89
89
|
|
90
|
+
// Public: pjax on form submit handler
|
91
|
+
//
|
92
|
+
// Exported as $.pjax.submit
|
93
|
+
//
|
94
|
+
// event - "click" jQuery.Event
|
95
|
+
// options - pjax options
|
96
|
+
//
|
97
|
+
// Examples
|
98
|
+
//
|
99
|
+
// $(document).on('submit', 'form', function(event) {
|
100
|
+
// var container = $(this).closest('[data-pjax-container]')
|
101
|
+
// $.pjax.submit(event, container)
|
102
|
+
// })
|
103
|
+
//
|
104
|
+
// Returns nothing.
|
105
|
+
function handleSubmit(event, container, options) {
|
106
|
+
options = optionsFor(container, options)
|
107
|
+
|
108
|
+
var form = event.currentTarget
|
109
|
+
|
110
|
+
if (form.tagName.toUpperCase() !== 'FORM')
|
111
|
+
throw "$.pjax.submit requires a form element"
|
112
|
+
|
113
|
+
var defaults = {
|
114
|
+
type: form.method,
|
115
|
+
url: form.action,
|
116
|
+
data: $(form).serializeArray(),
|
117
|
+
container: $(form).attr('data-pjax'),
|
118
|
+
target: form,
|
119
|
+
fragment: null,
|
120
|
+
timeout: 0
|
121
|
+
}
|
122
|
+
|
123
|
+
pjax($.extend({}, defaults, options))
|
124
|
+
|
125
|
+
event.preventDefault()
|
126
|
+
}
|
127
|
+
|
90
128
|
// Loads a URL with ajax, puts the response body inside a container,
|
91
129
|
// then pushState()'s the loaded URL.
|
92
130
|
//
|
@@ -294,7 +332,7 @@ function pjax(options) {
|
|
294
332
|
// Cache current container element before replacing it
|
295
333
|
cachePush(pjax.state.id, context.clone().contents())
|
296
334
|
|
297
|
-
window.history.pushState(null, "", options.
|
335
|
+
window.history.pushState(null, "", stripPjaxParam(options.requestUrl))
|
298
336
|
}
|
299
337
|
|
300
338
|
fire('pjax:start', [xhr, options])
|
@@ -525,13 +563,7 @@ function findContainerFor(container) {
|
|
525
563
|
//
|
526
564
|
// Returns a jQuery object.
|
527
565
|
function findAll(elems, selector) {
|
528
|
-
|
529
|
-
elems.each(function() {
|
530
|
-
if ($(this).is(selector))
|
531
|
-
results = results.add(this)
|
532
|
-
results = results.add(selector, this)
|
533
|
-
})
|
534
|
-
return results
|
566
|
+
return elems.filter(selector).add(elems.find(selector));
|
535
567
|
}
|
536
568
|
|
537
569
|
// Internal: Extracts container and metadata from response.
|
@@ -664,6 +696,7 @@ function enable() {
|
|
664
696
|
$.pjax.enable = $.noop
|
665
697
|
$.pjax.disable = disable
|
666
698
|
$.pjax.click = handleClick
|
699
|
+
$.pjax.submit = handleSubmit
|
667
700
|
$.pjax.reload = pjaxReload
|
668
701
|
$.pjax.defaults = {
|
669
702
|
timeout: 650,
|
@@ -694,6 +727,7 @@ function disable() {
|
|
694
727
|
$.pjax.enable = enable
|
695
728
|
$.pjax.disable = $.noop
|
696
729
|
$.pjax.click = $.noop
|
730
|
+
$.pjax.submit = $.noop
|
697
731
|
$.pjax.reload = window.location.reload
|
698
732
|
$(window).unbind('popstate.pjax', onPjaxPopstate)
|
699
733
|
}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pjax_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-08-
|
12
|
+
date: 2012-08-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: jquery-rails
|