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"
|
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:
|
Want to target that page in your Sass? Use a little string interpolation and a function that generates a selector:
|
||||||
|
|
||||||
``` sass
|
``` sass
|
||||||
|
|
|
@ -1,7 +1,11 @@
|
||||||
this.Bullseye = {
|
this.Bullseye = {
|
||||||
target: function(controller, action, callback) {
|
target: function(controller, actions, callback) {
|
||||||
this.targets[controller] = (this.targets[controller] || {});
|
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: {},
|
targets: {},
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
require 'tilt'
|
require 'tilt'
|
||||||
require 'bullseye/tilt/find_parts'
|
require 'bullseye/tilt/find_parts'
|
||||||
|
require 'json'
|
||||||
|
|
||||||
module Bullseye
|
module Bullseye
|
||||||
module Tilt
|
module Tilt
|
||||||
|
@ -17,7 +18,7 @@ module Bullseye
|
||||||
@scope = scope
|
@scope = scope
|
||||||
|
|
||||||
<<-JS
|
<<-JS
|
||||||
Bullseye.target('#{controller}', '#{action}', function() {
|
Bullseye.target('#{controller}', #{actions.to_json}, function() {
|
||||||
#{data}
|
#{data}
|
||||||
});
|
});
|
||||||
JS
|
JS
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
module Bullseye
|
module Bullseye
|
||||||
module Tilt
|
module Tilt
|
||||||
module FindParts
|
module FindParts
|
||||||
def action
|
def actions
|
||||||
parts.last
|
parts.last.split('-')
|
||||||
end
|
end
|
||||||
|
|
||||||
def controller
|
def controller
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
module Bullseye
|
module Bullseye
|
||||||
VERSION = "0.0.4"
|
VERSION = "0.0.5"
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue