From 65bc1034f53d60555ab5aad13afca504028c8fa1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vojte=CC=8Cch=20Dobes=CC=8C?= Date: Sun, 7 Jul 2013 22:20:19 +0200 Subject: [PATCH] [data-ajax-off] supports plain comma or space as separator [closes #71] --- nette.ajax.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/nette.ajax.js b/nette.ajax.js index c39c7bd..f02a1cb 100644 --- a/nette.ajax.js +++ b/nette.ajax.js @@ -177,8 +177,22 @@ var nette = function () { } if ($el.is('[data-ajax-off]')) { - settings.off = $el.data('ajaxOff'); + var rawOff = $el.attr('data-ajax-off'); + if (rawOff.indexOf('[') === 0) { + settings.off = $el.data('ajaxOff'); + } else if (rawOff.indexOf(',') !== -1) { + settings.off = rawOff.split(','); + } else if (rawOff.indexOf(' ') !== -1) { + settings.off = rawOff.split(' '); + } else { + settings.off = rawOff; + } if (typeof settings.off === 'string') settings.off = [settings.off]; + settings.off = $.grep($.each(settings.off, function (off) { + return $.trim(off); + }), function (off) { + return off.length; + }); } }