i have following greasemonkey script. adds button page has lot of buttons. clicking added button should trigger w/e function associated clicking other buttons. however, when click triggerallbutton, error typeerror: can't convert undefined object in console. ideas what's wrong code? replaced links in @include , @exclude ... don't want them public.
// ==userscript== // @name test stuff // @description test // @include ... // @require .../static/jquery.min.js // @require .../static/bootstrap/js/bootstrap.js // @require .../static/datatables/js/jquery.datatables.js // @require .../static/datatables/js/dt_bootstrap.js // @require .../static/toastr/toastr.js // ==/userscript== $(document).ready(function(){ $('.navbar-text.pull-right') .append('<input type="button" id="triggerallbutton" class="btn btn-info btn-small" value="trigger all">'); }); $(function(){ $('#triggerallbutton').click(function(e){ e.preventdefault(); $(".btn.trigger").each(function() { $(this).trigger(); }); }); });
you using .trigger() incorrectly, need pass @ least event type argument.
$('#triggerallbutton').click(function(e){ e.preventdefault(); $(".btn.trigger").trigger("click"); //.each implicit on jquery methods });
Comments
Post a Comment