Questions tagged [js-routes]

js-routes is a Ruby gem for Rails, which generates a javascript file defining all Rails named routes as javascript helpers/

22 questions
22
votes
6 answers

Acquire Asset Path from JavaScript

I need to display images on an HTML5 canvas that are in the Rails asset pipeline, but I need to know the path for the asset from JavaScript. I'm using js-routes for other parts of the application, but it doesn't appear to provide a way to get the…
senfo
  • 28,488
  • 15
  • 76
  • 106
6
votes
1 answer

Requiring a sprockets-preprocessed file with Browserify and browserify-rails

I'm using browserify-rails and I'm trying to get sprockets to preprocess a file that contains a sprockets directive, so that when I require() it using browserify, it will contain the generated JavaScript. The sprockets directive tries to include the…
kettlepot
  • 10,574
  • 28
  • 71
  • 100
5
votes
3 answers

webpacker: including javascript from a gem (js-routes)

I'm trying to use the JS routes gem with webpacker from Rails 5.1 but can't figure out how to include the js-routes.js.erb in webpack's app/javascript/packs/application.js. import 'js-routes' leads to Uncaught Error: Cannot find module…
4
votes
1 answer

Append locale parameter to all paths generated by js-routes gem in rails

I am using js-routes gem (https://github.com/railsware/js-routes) with Rails 4.0.0. What I want to do is include the current locale string in every route generated by js-routes in my rails app. And this locale string (e.g. "en") will be pulled from…
csum
  • 1,782
  • 13
  • 15
2
votes
3 answers

js-routes adding (::format) to urls

I have a simple rails project that I've been playing around in with reactjs. To add some basic navigation, I brought the js-routes library in and it works great for urls that have a path parameter such as "localhost:3000/addresses/1". The problem I…
gwnp
  • 1,127
  • 1
  • 10
  • 35
1
vote
0 answers

Popup in Deck.gl when using Routes

I'm using deck.gl and routes in my JS app and am having some trouble with popups. If I use deck.gl as a standalone (without routes) then I can display popups, but using exactly the same code in a routes framework fails. The console shows that the…
os1
  • 412
  • 1
  • 6
  • 18
1
vote
0 answers

Rails js-routes: get path

In my rails app I'm trying to make a transition link in my javascript file with help of js-routes gem $.get(Routes.pay_account_path(self.tour.ID(), {format: 'html'}), function () { return true; }); This code seems correct, but there is no…
Pavel
  • 1,934
  • 3
  • 30
  • 49
1
vote
1 answer

How do I activate an Iron Router route without changing the path?

In my Meteor app, I'm trying to pass data from my Iron Router controller to a template that's a partial in my app. How do I activate a route without changing the path? I don't want to switch pages, only render the partial with my data (if that makes…
Stu Stein
  • 888
  • 7
  • 6
1
vote
1 answer

Running js-routes with Rails and Heroku

Is there any known way to run the js-routes gem on Heroku? The trouble seems to stem from the fact that the routes can't be compiled when the App isn't mounted (because it needs access to the Rails routes), but Heroku won't let you set…
Stephen Corwin
  • 968
  • 1
  • 8
  • 21
1
vote
1 answer

js-routes ASP.NET MVC alternative

So, I have been tasked with rewriting a prototype ruby app back-end to .NET, and have stumbled onto a gem called js-routes. You can read about this here: https://github.com/railsware/js-routes/ This gem appears to generate JavaScript objects for…
BlakeH
  • 3,354
  • 2
  • 21
  • 31
0
votes
2 answers

how can I get location href in all entered urls by js

I am actually looking for a way to get all the URLs entered so that I can redirect the wrong URLs to a 404 page. when I hit different url s like localhost:0000/details, because location.href is in index.html, this code is not executed. and I can't…
Husen
  • 185
  • 1
  • 10
0
votes
1 answer

Routes config on next-routes

On my project, I'm using React + Next.js. For routes, I use the library next-routes. When you navigate the nested route "{category alias}/filter" the page reloads. Add route - routes.add ({name: 'products', pattern: '/:noname/filter', page:…
0
votes
2 answers

Routing in Javascript (multiple files)

I am accessing api.js from Routes.js but I am getting an error that function my_function_in_api is not defined. My code is as follows, please advise where is the problem: Routes.js var val = require('file name') modules.exports =…
Tabz
  • 137
  • 1
  • 11
0
votes
1 answer

express routes do not load again

I'm encountering a problem with the express routes. Here's my case: I have a node js app with the following code in app.js var express = require('express'); var app = express(); var path = require('path'); var bodyParser =…
g_tech
  • 251
  • 1
  • 4
  • 13
0
votes
1 answer

How to import library-generated IIEF style JavaScript file?

Is there any way to import some library-generated code which does not have export vars? Which module options should be set in tsconfig.json file? Documents about "Module" system in TypeScript Environment typescript @2.3.2 js-routes…
kenju
  • 5,866
  • 1
  • 41
  • 41
1
2