1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| var $eventLog = $(".js-event-log"); var $eventSelect = $(".js-example-events"); $eventSelect.on("select2:open", function (e) { log("select2:open", e); }); $eventSelect.on("select2:close", function (e) { log("select2:close", e); }); $eventSelect.on("select2:select", function (e) { log("select2:select", e); }); $eventSelect.on("select2:unselect", function (e) { log("select2:unselect", e); }); $eventSelect.on("change", function (e) { log("change"); }); function log (name, evt) { if (!evt) { var args = "{}"; } else { var args = JSON.stringify(evt.params, function (key, value) { if (value && value.nodeName) return "[DOM node]"; if (value instanceof $.Event) return "[$.Event]"; return value; }); } var $e = $("<li>" + name + " -> " + args + "</li>"); $eventLog.append($e); $e.animate({ opacity: 1 }, 10000, 'linear', function () { $e.animate({ opacity: 0 }, 2000, 'linear', function () { $e.remove(); }); }); }
|