Sha256: df7f944431058b7eaabf41b68d79f8a0f0c327a8eb2b98a7622073c8f7baee09
Contents?: true
Size: 1.94 KB
Versions: 3
Compression:
Stored size: 1.94 KB
Contents
//= require selectize $(document).ready(function () { var selectizeCallback = null; $(".selectize_with_add").each(function(i, item) { $(item).selectize({ create: function(input, callback) { selectizeCallback = callback; $("." + $(item).data('model') + "-modal").modal(); $("#" + $(item).data('model') + "_name").val(input); } }); $("." + $(item).data('model') + "-modal").on("hide.bs.modal", function(e) { if (selectizeCallback != null) { selectizeCallback(); selecitzeCallback = null; } $("#new_" + $(item).data('model') + "").trigger("reset"); $("#new_" + $(item).data('model') + " select").val(null).trigger('change'); $.rails.enableFormElements($("#new_" + $(item).data('model') + "")); }); $("#new_" + $(item).data('model')).on("submit", function(e) { e.preventDefault(); $.ajax({ method: "POST", dataType: "json", url: $(this).attr("action"), data: $(this).serialize(), success: function(response) { selectizeCallback({value: response.id, text: response.name}); selectizeCallback = null; $("." + $(item).data('model') + "-modal").modal('toggle'); } }); }); }); $(".selectize_with_add_without_modal").each(function(i, item) { $(item).selectize({ create: function(input, callback) { selectizeCallback = callback; data = {}; data[$(item).data('model')] = {}; data[$(item).data('model')][$(item).data('field')] = input; $.ajax({ method: "POST", dataType: "json", url: "/" + $(item).data('pluralized'), data: data, success: function(response) { selectizeCallback({value: response.id, text: response.name}); } }); selectizeCallback = callback; } }); }); });
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
zutils-0.2.8 | app/assets/javascripts/zutils.js |
zutils-0.2.7 | app/assets/javascripts/zutils.js |
zutils-0.2.6 | app/assets/javascripts/zutils.js |