html - javascript custom event fire from a function with returning false -


i have following form code. , have prevent form submission , after firing custom event. have written javascript on submit function triggering event , return false, please if doing wrong.

form html:

   <form class="form-inline" action="" name="filterform">       <div class="row">         <?php foreach($formatted_post_type $filters){?>         <div class="checkbox">           <label class="checkbox-inline" style="line-height:40px;">             <input type="checkbox" name="filters[posttype][]" value="<?php echo $filters['slug']?>" onclick="refresh_posttypes();" />             <?php echo $filters['name']?></label>         </div>         <?php }?>       </div>       <div class="row">         <div class="col-md-12">           <input type="submit" class="btn btn-primary btn-sm" value="apply">         </div>       </div>     </form> 

javascript code:

jquery(document).ready(function(){   jquery('form[name="filterform"]').on('submit', function(e){       jquery(document).triggerhandler('favorites-update-all-lists', function(e){            e.preventdefault();     });     return false;     });   }); 

try moving e.preventdefault(); right after submit handler:

jquery(document).ready(function(){   jquery('form[name="filterform"]').on('submit', function(e){       e.preventdefault();        jquery(document).triggerhandler('favorites-update-all-lists', function(e){        });     return false;     });   }); 

Comments

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -

recursion - Can every recursive algorithm be improved with dynamic programming? -