js-routes

Acquire Asset Path from JavaScript

喜欢而已 提交于 2019-12-21 06:56:09
问题 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 path to something in the asset pipeline. What's the correct way to obtain the path to a Rails asset (e.g., an image) from JavaScript? 回答1: In the Rails Asset Pipeline guide, they give an example of coding assets in your stylesheets by preprocessing

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

倖福魔咒の 提交于 2019-12-13 12:41:44
问题 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 sense). Here's how the app works: Right now, the route is activated when I click a dropdown link in my navbar Template.navbar.events 'click #threads-link': (event)-> Router.go 'allThreads' This renders the template with my data as long as I have a

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

旧巷老猫 提交于 2019-12-08 21:00:30
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 sense). Here's how the app works: Right now, the route is activated when I click a dropdown link in my navbar Template.navbar.events 'click #threads-link': (event)-> Router.go 'allThreads' This renders the template with my data as long as I have a path in my route. But since I don't want the path to change, I tried leaving the path--and then the

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

大兔子大兔子 提交于 2019-12-06 00:34:00
问题 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 output of the gem js-routes, in order to allow me to access the Rails routes from the clientside. This is my setup (within app/assets/javascripts ): system/ rails_routes.js application.js application.js is the main file, and it runs the rest of

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

徘徊边缘 提交于 2019-12-04 06:53:53
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 output of the gem js-routes , in order to allow me to access the Rails routes from the clientside. This is my setup (within app/assets/javascripts ): system/ rails_routes.js application.js application.js is the main file, and it runs the rest of the application. I would like to be able to do something like var rr = require("./system/rails_routes.js

Acquire Asset Path from JavaScript

别等时光非礼了梦想. 提交于 2019-12-03 22:27:22
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 path to something in the asset pipeline. What's the correct way to obtain the path to a Rails asset (e.g., an image) from JavaScript? In the Rails Asset Pipeline guide , they give an example of coding assets in your stylesheets by preprocessing the stylesheets with ERB. You can use the same technique with JavaScript, assuming you tack an .erb to the