text: $(function() {
  
      $('form').parsley();
      $("#form_create").submit(function(event) {
          event.preventDefault();
          save();
      });
  
      $("#form_edit").submit(function(event) {
          event.preventDefault();
          update();
      });
      showEdit();
  });
  
  //guardar en el form
  const save = () => {
      let form = $('#form_create');
      $.ajax({
          data: form.serialize(),
          url: form.attr('action'),
          type: form.attr('method'),
          dataType: 'json',
          success: function(data) {
  
              if (data.success) {
  
                  success(data.success);
                  $('#form_create')[0].reset();
                  updateTable();
              } else {
                  warning(data.warning);
  
              }
  
          },
          error: function(data) {
  
              if (data.status === 422) {
                  let errors = $.parseJSON(data.responseText);
                  addErrorMessage(errors);
              }
          }
      });
  
  }
  
  //actualizar-editform
  const update = () => {
      let form = $('#form_edit');
      $.ajax({
          data: form.serialize(),
          url: form.attr('action'),
          type: form.attr('method'),
          dataType: 'json',
          success: function(data) {
  
              if (data.success) {
                  success(data.success);
                  $('#modalEdit').modal('hide');
                  updateTable();
              } else {
                  warning(data.warning);
              }
  
          },
          error: function(data) {
  
              if (data.status === 422) {
                  let errors = $.parseJSON(data.responseText);
                  addErrorMessage(errors);
              }
          }
      });
  
  }
  
  
  const showEdit = () => {
      $('#modalEdit').on('show.bs.modal', function(event) {
          let button = $(event.relatedTarget)
          let id = button.data('id');
          let nombre = button.data('nombre');
          let carpeta_recurso_id=button.data('carpeta_recurso_id')
          let modal = $(this);
  
          modal.find('.modal-body #id').val(id);
          modal.find('.modal-body #nombre_e').val(nombre);
          $("#carpeta_recurso_id option[value='" + carpeta_recurso_id + "']").attr("selected", true);
  
      });
  }
  
  //FUNCION DE ESTADOS
  const changeEstado = (url) => {
      $.ajax({
          url: url,
          type: 'GET',
          dataType: 'json',
          success: function(data) {
  
              if (data.success) {
                  success(data.success);
                  updateTable();
              } else {
                  warning(data.warning);
              }
  
          },
      });
  }