Skip to content

Instantly share code, notes, and snippets.

@diego-carrera
Created April 10, 2012 22:54
Show Gist options
  • Save diego-carrera/2355322 to your computer and use it in GitHub Desktop.
Save diego-carrera/2355322 to your computer and use it in GitHub Desktop.
Cargar Formas en un dialog de jqueryui
$('a.form-dialog').live('click', function(){
$('<div id="form-dialog-container"></div>').dialog({
modal:true,
title:$(this).attr('title'),
autoOpen:false,
buttons:{
Cancelar:function(){
$(this).dialog('close'); $('.ui-dialog, #form-dialog-container').remove();
},
Aceptar:function(){
var form = $('#form-dialog-container form:first-child');
$.ajax({
type: $(form).attr('method'),
url: $(form).attr('action'),
data: $(form).serialize(),
dataType: 'json',
success: function(response) {
if ( response.success ) {
$('#form-dialog-container').dialog('close');
$('.ui-dialog, #form-dialog-container').remove();
$.gritter.add({title:'Info', text:response.data});
var selected = $('div.tabs').tabs('option', 'selected');
$('div.tabs').tabs('load', selected);
} else {
$.gritter.add({title:'Error', text:response.data});
}
}
});
}
}
}
).load($(this).attr('href'), function(){
$(this).dialog('open');
});
return false;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment