any reason why trigger function is not working? (jquery) -


i have code below.

when trigger #tempbutton #searchbutton (with object parameter), works fine. when i'm doing same thing #myid, won't trigger.

any ideas doing wrong? thanks

here's code. please assume getajax called somewhere. it's had stripped lot of code make short/readable. part works. :)

var onclickmyid = function(event, parameters) {     event.preventdefault();      console.log(event.data); //works. displays listlength passed      $("#tempbutton").trigger("click", [ "test" ]); // works obviously, won't object     //$("#tempbutton").trigger("click", [{ name:"test" }]); // doesn't work although it' same 1 below };  var onclicktempbutton = function(event, parameters) { console.log(parameters); }  var onclicksearchbutton = function(event) {     event.preventdefault();      $("#tempbutton").trigger("click", [{ name:"test" }]); //works };  $(document).on("click", "#tempbutton", onclicktempbutton);  $(document).on("click", "#searchbutton", onclicksearchbutton);  function getajax() {     $.ajax({         url: my-url-here         , cache: false         , datatype: "json"         , data: {}         , success: function(data, status) {             displaytopiclist({ data:data });         }     }); }  function displaytopiclist(parameters) {     $.each(parameters.data, function(index, option) {         $("#mylinks").append($("<a></a><br />").attr("id", "myid"+option.id).attr("href", "javascript:void(0)");     });      $(document).on("click", "[id^=myid]", { listlength:parameters.data.length }, onclickmyid); } 


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -