Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uncaught TypeError: Cannot create property 'guid' on string ' [duplicate]

I am a attempting to run the below jQuery .on() method with the parameter value of 10 however whenever I do I get an

Uncaught TypeError

 $(document).on("click", '.topic-btn', displayGIF(10));

It's my understanding that how it is written runs the function without a click event causing the error.

Is there a way around this? Ultimately, I want the .on("click"... for a parameter value of 10 and a .on("dblcick"... for a parameter value of 20.

like image 447
A. Andersen Avatar asked Sep 16 '25 21:09

A. Andersen


1 Answers

You can change the code to this:

$(document).on("click", '.topic-btn', {'param': 10}, function(event){
     displayGIF(event.data.param);
});

The data to on can be passed using the above method. Refer docs: http://api.jquery.com/on/

like image 62
dRoyson Avatar answered Sep 18 '25 17:09

dRoyson