//= require jquery //= require jquery_ujs //= require jquery-ui //= require tiny_mce/jquery.tinymce.js //= require spud/admin/jquery.dataTables.min //= require_self //= require_tree . $(document).ready(function() { $('#user_table').dataTable({ "bJQueryUI": true, "sPaginationType": "full_numbers", }); $('a.ajax').live('click', function() { var url = this.href; var title = this.title; var dialog = $("#dialog"); if(dialog.length == 0) { dialog = $('
').appendTo('body'); } dialog.load(url + ".js",null, function(responseText, textStatus, XMLHttpRequest) { dialog.dialog({width:500,modal:true,height:500,title:title}); }) return false; }); $('a.close_dialog').live('click', function() { $('#dialog').dialog('close'); }) $('a[data-method="delete"]').live('ajax:success', function(data, textStatus, jqXHR){ $(this).closest('tr').fadeOut(); }); $('form[data-remote="true"]').live('ajax:success', function(data, textStatus, jqXHR){ $(this).closest('#dialog').dialog('close'); console.log(data) }); $('a.button').button(); initFormTabs(); } ); function remove_fields(link) { $(link).prev("input[type=hidden]").val("1"); $(link).closest(".fields").hide(); } function add_fields(link, association, content) { var new_id = new Date().getTime(); var regexp = new RegExp("new_" + association, "g") $(link).parent().before(content.replace(regexp, new_id)); } function initFormTabs(){ var tabNames = []; $('.formtabs .formtab').each(function(tabind) { this.id = 'tab-' + tabind; tabNames.push($('.tab_name',this).first().val()) }); var tabButtons = $('.formtabs .formtab_buttons').first(); for(var x=0;x