Skip to content

Commit 1ff1040

Browse files
committed
Refactor Ajax features and add ajax setting in nmObj
1 parent 2a1e1af commit 1ff1040

3 files changed

Lines changed: 16 additions & 17 deletions

File tree

js/jquery.nyroModal.filters.form.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,12 @@ jQuery(function($, undefined) {
2525
},
2626
load: function(nm) {
2727
var data = {};
28-
$.map(nm.opener.serializeArray(), function(d){
28+
$.map(nm.opener.serializeArray(), function(d) {
2929
data[d.name] = d.value;
3030
});
3131
if (nm.store.form.sel)
3232
data[nm.selIndicator] = nm.store.form.sel.substring(1);
33-
34-
var ajax = $.extend(true, { type : 'get', dataType : 'text' }, nm.ajax || {}, {
33+
$.ajax($.extend(true, { type : 'get', dataType : 'text' }, nm.ajax || {}, {
3534
url: nm.store.form.url,
3635
data: data,
3736
type: nm.opener.attr('method') ? nm.opener.attr('method') : undefined,
@@ -41,9 +40,7 @@ jQuery(function($, undefined) {
4140
error: function(jqXHR) {
4241
nm._error(jqXHR);
4342
}
44-
});
45-
46-
$.ajax(ajax);
43+
}));
4744
},
4845
destroy: function(nm) {
4946
nm.opener.off('submit.nyroModal');

js/jquery.nyroModal.filters.link.js

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,16 @@ jQuery(function($, undefined) {
2424
});
2525
},
2626
load: function(nm) {
27-
var ajax = $.extend(true, {}, nm.ajax || {}, {
28-
url: nm.store.link.url,
29-
data: nm.store.link.sel ? [{name: nm.selIndicator, value: nm.store.link.sel.substring(1)}] : undefined,
30-
success: function(data) {
31-
nm._setCont(data, nm.store.link.sel);
32-
},
33-
error: function(jqXHR) {
34-
nm._error(jqXHR);
35-
}
36-
});
37-
$.ajax(ajax);
27+
$.ajax($.extend(true, {}, nm.ajax || {}, {
28+
url: nm.store.link.url,
29+
data: nm.store.link.sel ? [{name: nm.selIndicator, value: nm.store.link.sel.substring(1)}] : undefined,
30+
success: function(data) {
31+
nm._setCont(data, nm.store.link.sel);
32+
},
33+
error: function(jqXHR) {
34+
nm._error(jqXHR);
35+
}
36+
}));
3837
},
3938
destroy: function(nm) {
4039
nm.opener.off('click.nyroModal');

js/jquery.nyroModal.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ jQuery(function($, undefined) {
3838
// Specific confirguation for DOM filter
3939
domCopy: false, // Indicates if DOM element should be copied or moved
4040

41+
// Specific confirguation for link and form filters
42+
ajax: {}, // Ajax options to be used in link and form filter
43+
4144
// Specific confirguation for image filter
4245
imageRegex: '[^\.]\.(jpg|jpeg|png|tiff|gif|bmp)\s*$', // Regex used to detect image link
4346

0 commit comments

Comments
 (0)