search multiple actions
This commit is contained in:
parent
b23ad87ad8
commit
cf004ac1d8
@ -52,6 +52,14 @@ alert("I am showing a site");
|
||||
alert "I am also showing a site"
|
||||
```
|
||||
|
||||
Want to use the same JavaScript for two actions, say `new` and `edit`? Put both actions in the filename separated by a dash:
|
||||
|
||||
``` coffeescript
|
||||
# app/assets/javascripts/bullseye/sites/new-edit.bullseye.coffee
|
||||
|
||||
alert "I appear on both the new and edit actions"
|
||||
```
|
||||
|
||||
Want to target that page in your Sass? Use a little string interpolation and a function that generates a selector:
|
||||
|
||||
``` sass
|
||||
|
@ -1,7 +1,11 @@
|
||||
this.Bullseye = {
|
||||
target: function(controller, action, callback) {
|
||||
target: function(controller, actions, callback) {
|
||||
this.targets[controller] = (this.targets[controller] || {});
|
||||
this.targets[controller][action] = callback;
|
||||
|
||||
var actions_i;
|
||||
for (actions_i = 0; actions_i < actions.length; ++actions_i) {
|
||||
this.targets[controller][actions[actions_i]] = callback;
|
||||
}
|
||||
},
|
||||
|
||||
targets: {},
|
||||
|
@ -1,5 +1,6 @@
|
||||
require 'tilt'
|
||||
require 'bullseye/tilt/find_parts'
|
||||
require 'json'
|
||||
|
||||
module Bullseye
|
||||
module Tilt
|
||||
@ -17,7 +18,7 @@ module Bullseye
|
||||
@scope = scope
|
||||
|
||||
<<-JS
|
||||
Bullseye.target('#{controller}', '#{action}', function() {
|
||||
Bullseye.target('#{controller}', #{actions.to_json}, function() {
|
||||
#{data}
|
||||
});
|
||||
JS
|
||||
|
@ -1,8 +1,8 @@
|
||||
module Bullseye
|
||||
module Tilt
|
||||
module FindParts
|
||||
def action
|
||||
parts.last
|
||||
def actions
|
||||
parts.last.split('-')
|
||||
end
|
||||
|
||||
def controller
|
||||
|
@ -1,3 +1,3 @@
|
||||
module Bullseye
|
||||
VERSION = "0.0.4"
|
||||
VERSION = "0.0.5"
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user