Ver Mensaje Individual
  #4 (permalink)  
Antiguo 02/10/2014, 10:46
Avatar de JessicaTJ
JessicaTJ
 
Fecha de Ingreso: enero-2007
Ubicación: 127.0.0.1
Mensajes: 472
Antigüedad: 17 años, 3 meses
Puntos: 25
Respuesta: BootstrapValidator y envio de formas via ajax

Ya logre hacer que envie la forma, pero ahora, no me actualiza si el resultado es positivo:

Código Javascript:
Ver original
  1. $(document).ready(function() {
  2.     $('#newsForm').bootstrapValidator({
  3.             // Only disabled elements are excluded
  4.             // The invisible elements belonging to inactive tabs must be validated
  5.             excluded: [':disabled'],
  6.             trigger: 'focus blur keyup',
  7.             feedbackIcons: {
  8.                 valid: 'icon-ok',
  9.                 invalid: 'icon-remove',
  10.                 validating: 'icon-refresh'
  11.             },
  12.             fields: {
  13.                 //field data here.
  14.             }
  15.         })
  16.         // Called when a field is invalid
  17.         .on('error.field.bv', function(e, data) {
  18.             // data.element --> The field element
  19.  
  20.             var $tabPane = data.element.parents('.tab-pane'),
  21.                 tabId    = $tabPane.attr('id');
  22.  
  23.             $('a[href="#' + tabId + '"][data-toggle="tab"]')
  24.                 .parent()
  25.                 .find('i')
  26.                 .removeClass('fa-check')
  27.                 .addClass('fa-times');
  28.         })
  29.         // Called when a field is valid
  30.         .on('success.field.bv', function(e, data) {
  31.             // data.bv      --> The BootstrapValidator instance
  32.             // data.element --> The field element
  33.  
  34.             var $tabPane = data.element.parents('.tab-pane'),
  35.                 tabId    = $tabPane.attr('id'),
  36.                 $icon    = $('a[href="#' + tabId + '"][data-toggle="tab"]')
  37.                             .parent()
  38.                             .find('i')
  39.                             .removeClass('fa-check fa-times');
  40.  
  41.             // Check if the submit button is clicked
  42.             if (data.bv.getSubmitButton()) {
  43.                 // Check if all fields in tab are valid
  44.                 var isValidTab = data.bv.isValidContainer($tabPane);
  45.                 $icon.addClass(isValidTab ? 'fa-check' : 'fa-times');
  46.             }
  47.         }).on('success.form.bv', function(e) {
  48.               submit();
  49.         });
  50.     });
  51.    
  52. function submit(){
  53.       $('#newsForm').submit(function(){
  54.               $.post("enviar_datos.php", $('#newsForm').serialize(),function(data){
  55.                          if (data.success){
  56.                             $('#newsForm').find('.well').slideUp('normal', function (){
  57.                             $('#newsForm').html(data);
  58.                             });
  59.                          }else{
  60.                                     window.alert('Failed');
  61.                          }
  62.               }, 'json');
  63.               return false;
  64.    });
  65. }

help please? :3
__________________
٩(͡๏̯͡๏)۶ || ٩(͡๏̯͡๏)۶