Beruflich Dokumente
Kultur Dokumente
#2 Blog
link, link2
The Solution
#4 Class Scoping
scope the body element of the layouts with the controller and action name
// app/assets/javascripts/application.js
#4 Initialization
# app/assets/javascript/init.coffee
window.App ||= {}
App.init = >
$("a, span, i, div").tooltip()
全局可以是使⽤App
App.init()
// app/assets/javascripts/application.js
# app/assets/javascript/app.chart.coffee
class App.Chart
constructor: (@el) =>
# initilize some stuff
render: ->
# do some stuff
#4 Structure
|
|
class definition
|
|
|
|
invocation
|
|
先定义⼀个js class
然后调⽤它
#4 Page-Specific Javascript
应为page-specific的情况不是很常⻅,所以⽤如下办法
# .......
#4 User-Triggered Javascript
App.Billing =
update: ->
# do some stuff
use on
#4 Add to Manifest
link
#2 Viedo
link
#2 Wiki
js document of Defining classes
#2 Search
link