-
Notifications
You must be signed in to change notification settings - Fork 14
JavascriptComponents
This section covers the specifics of setting up an application using the sinatra_more generators and each javascript component.
To use jquery in your new project, simply invoke the generator:
sinatra_gen demo_app . -s jqueryThen you will need to require jquery in your template file or layout:
# app/views/layout.rb
#...
<head>
# ...
<%= javascript_include_tag 'jquery.min', 'application' %>
# ...
</head>Finally we can use jquery within our application:
# public/javascripts/application.js
$(document).ready(function() {
// put all your jQuery goodness in here.
});For more information on jquery, check out the jquery documentation
To use prototype in your new project, simply invoke the generator:
sinatra_gen demo_app . -s prototypeThen you will need to require prototype in your template file or layout:
# app/views/layout.rb
#...
<head>
# ...
<%= javascript_include_tag 'prototype', 'lowpro', 'application' %>
# ...
</head>Finally we can use prototype within our application:
# public/javascripts/application.js
document.observe('dom:loaded', function(ev) {
// standard prototype here
});
Event.addBehavior({
// lowpro behavior definitions here
});
For more information on prototype, check out the prototype documentation
For more information on lowpro, check out the lowpro blog (Lowpro really needs better docs!)
To use rightjs in your new project, simply invoke the generator:
sinatra_gen demo_app . -s rightjsTo use rightjs in your new project, simply invoke the generator:
sinatra_gen demo_app . -s rightjsThen you will need to require rightjs in your template file or layout:
# app/views/layout.rb
#...
<head>
# ...
<%= javascript_include_tag 'right-min', 'application' %>
# ...
</head>Finally we can use rightjs within our application:
# public/javascripts/application.js
document.onReady(function() {
// put rightjs code here
});For more information on rightjs, check out the RightJS documentation