jQuery(function($) { "use strict"; var TEMPLATES = new LuigiTemplate.Cache({ }); $('.add-post').click(function() { var type = $(this).data('type'); // dismiss dropdown $('body').trigger('click'); send(type + '/add').fail(function(r) { var msg = r.responseText; try { var data = $.parseJSON(r); if (data.error) msg = data.error; } catch (e) {} alert('Error: ' + msg); }).done(function(r) { console.log(r); // show edit dialog $('#' + type + '-edit-dialog').data('post_id', r.post_id).modal('show') }); // stop event return false; }); });