dist/bbn.js
/**
     * Submit a form's data through an Ajax request.
     * 
     * It will also prevent the event if given, and execute the given callback, 
     * or look for one in the data-script attribute.
     * 
     * @method   submit
     * @global   
     * @memberof bbn.fn
     * @fires    {*}           
     * @fires    {*}           
     * 
     * @param    {HTMLElement} form The form to submit
     * @param    {Event}       e    The optional submit event - which will be prevented
     * @param    {Function}    fn   An optional callback function
     * 
     * @returns  {*}           
     */
Submit a form's data through an Ajax request.

It will also prevent the event if given, and execute the given callback,
or look for one in the data-script attribute.



@param    {HTMLElement} form The form to submit
@param    {Event}       e    The optional submit event - which will be prevented
@param    {Function}    fn   An optional callback function


Submit a form ' s data through an Ajax request . It will also prevent the event if given and execute the given callback or look for one in the data - script attribute . @param { HTMLElement } form The form to submit @param { Event } e The optional submit event - which will be prevented @param { Function } fn An optional callback function
submit(form, e, fn){
      let url = form.getAttribute("action") || bbn.env.path,
          data;
      if ( url === '' ){
        url = '.';
      }
      if ( (typeof(url) === 'string') && (url.indexOf("http") !== 0 || url.indexOf(window.document.location.hostname) !== -1) && !form.getAttribute("target") ){  
        if ( e ){
          e.preventDefault();
        }
        data = bbn.fn.formdata(form);
        if ( data ){
          form.setAttribute('action', null);          
          form.dataset.bbnSubmit = 1;
          let script = form.dataset.script;
          if ( bbn.fn.isFunction(script) ){
            form.dataset.script = d =>{
              form.setAttribute("action", url);
              script(d);
            };
          }
          if (!fn) {
            fn = form.getAttribute("data-script");
          }
          if (fn) {
            if (bbn.fn.isString(fn)) {
              fn = eval(fn);
            }
            bbn.fn.post(url, data, fn);
          }
          else{
            bbn.fn.post(url, data);
          }
        }
      }
    }
submit ( form , e , fn ) { let url = form . getAttribute ( "action" ) || bbn . env . path , data ; if ( url === '' ) { url = '.' ; } if ( ( typeof ( url ) === 'string' ) && ( url . indexOf ( "http" ) !== 0 || url . indexOf ( window . document . location . hostname ) !== - 1 ) && ! form . getAttribute ( "target" ) ) { if ( e ) { e . preventDefault ( ) ; } data = bbn . fn . formdata ( form ) ; if ( data ) { form . setAttribute ( 'action' , null ) ; form . dataset . bbnSubmit = 1 ; let script = form . dataset . script ; if ( bbn . fn . isFunction ( script ) ) { form . dataset . script = d => { form . setAttribute ( "action" , url ) ; script ( d ) ; } ; } if ( ! fn ) { fn = form . getAttribute ( "data-script" ) ; } if ( fn ) { if ( bbn . fn . isString ( fn ) ) { fn = eval ( fn ) ; } bbn . fn . post ( url , data , fn ) ; } else { bbn . fn . post ( url , data ) ; } } } }
Submit a form's data through an Ajax request.
Submit a form ' s data through an Ajax request .
//if ( (typeof(url) === 'string') && (url.indexOf("http") !== 0 || url.indexOf(window.document.location.hostname) !== -1) && !form.is("[target]") ){ //$form.attr("action", null); //$form.data("bbnSubmit", 1); //var script = $form.data("script"); /*$form.data("script", function(d){
              $form.attr("action", url);
              script(d);
            })*/