javascript - How to associate onClick with a dynamically generated div with dojo? -


i using dojo 1.9.2, , trying attach onclick function on piece of html code created on fly, this:

clickablediv = "<div data-dojo-attach-point=\"testbtn\">click me!</div>"; self.racks.innerhtml = clickablediv; 

and want give onclick function after, right below code putted:

connect(this.testbtn, "onclick", alert("you clicked it!")); 

for reason not wont work, when refresh page alert "you clicked it!" pop without me clicking anything...

i have use dojo version, it's part of requirement... idea or suggestion on how can go doing this?

well, dojo part of javascript, can use javascript function, example:

clickablediv = "<div id=\"testbtn\">click me!</div>"; self.racks.innerhtml = clickablediv; document.getelementbyid('testbtn').onclick=function(){alert("you clicked it!");}; 

Comments

Popular posts from this blog

php - SPIP: From Tag directly to an article -

jquery - isAjaxRequest always return false -

ruby on rails - In a controller spec, how to find a specific tag in the generated view? -