gon icon indicating copy to clipboard operation
gon copied to clipboard

gon.watch is broken

Open passion8 opened this issue 11 years ago • 8 comments

because gon.watch is not window variable, i can't access it. Currently, it returns undefinded. Let me know if you need PR from my side to fix this.

passion8 avatar Nov 08 '14 14:11 passion8

Hello! But gon.watch is not a variable - it is a function. https://github.com/gazay/gon/wiki/Usage-gon-watch

gazay avatar Nov 08 '14 14:11 gazay

Yes, It is. And, the expected response should be the function i guess rather then undefined. isn't it happening with you ?

Little bit of background, we are using turbolinks (with rails 4) , i have included this in our body

  = include_gon(:namespace => 'gt')

due to the nature of turbolinks.

passion8 avatar Nov 08 '14 14:11 passion8

Actually I see more problems with watch now - it ignores namespace option.

Anyway - how you think it can be solved?

gazay avatar Nov 08 '14 15:11 gazay

oh yea. it does.

I wasn't aware of the code so I am not exactly fully aware of the problem and its scope. Tomorrow is sundae..I will have a look on it and see what I can do.

Looking at hight level i think we need to pass the namespace variable to those functions. That can be done easily. Since, with render_data method you are already rendering the javascript variable. We can just assign that variable to those javascript function.

passion8 avatar Nov 08 '14 16:11 passion8

are there any news on this? gon.watch is also undefined in my case.

ghost avatar Jun 30 '15 13:06 ghost

gon.watch is still unaware and doesn't work when you use namespace.

YanivRan avatar May 13 '16 18:05 YanivRan

In my ajax success callback I've updated gon.variable = ajax_result_parsed. It works! :)

Alagaesia93 avatar Sep 15 '16 14:09 Alagaesia93

@Alagaesia93, not sure how is that related?

YanivRan avatar Sep 16 '16 15:09 YanivRan