gazay / gon

Your Rails variables in your JS
MIT License
3.05k stars 184 forks source link

Is there a way to update gon through a remote call (JS)? #249

Closed rept closed 6 years ago

rept commented 6 years ago

I now have an element on my page like this:

= link_to raw('<i class="fa fa-caret-left"> </i>'), root_path(period: -1), :remote => true

This does a call that gets handled in the controller by format.js

In the dashboard.js.erb view I want to replace the gon values.

With the following hack this works:

<%= raw(include_gon.sub('<script>','').sub('//<![CDATA[','').sub('//]]>','').sub('</script>','')) %>

However, I think it could be useful to include a include_pure_js_gon that doesn't contain the Githubissues.

  • Githubissues is a development platform for aggregating issues.