From e2ea6faac7b3f86183b6d883f035881cd1ed826d Mon Sep 17 00:00:00 2001 From: Igor Vaynberg Date: Mon, 30 Jul 2012 13:32:29 +0300 Subject: [PATCH] allow url to be specified via data-ajax-url attribute. fixes #275 --- select2.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/select2.js b/select2.js index 53d79d82..4bbb121f 100755 --- a/select2.js +++ b/select2.js @@ -1,4 +1,4 @@ -/* +/* Copyright 2012 Igor Vaynberg Version: @@ver@@ Timestamp: @@timestamp@@ @@ -563,7 +563,7 @@ // abstract prepareOpts: function (opts) { - var element, select, idKey; + var element, select, idKey, ajaxUrl; element = opts.element; @@ -674,6 +674,10 @@ } else { if (!("query" in opts)) { if ("ajax" in opts) { + ajaxUrl = opts.element.data("ajax-url"); + if (ajaxUrl && ajaxUrl.length > 0) { + opts.ajax.url = ajaxUrl; + } opts.query = ajax(opts.ajax); } else if ("data" in opts) { opts.query = local(opts.data);