An Ember application starts with its main template. Put your header, footer, and any other decorative content in application.handlebars.
<header>
<img src="masthead">
</header>
<footer>
| var FormView = Backbone.View.extend({ | |
| el: '#form', | |
| events: { | |
| // Fired automatically when a file-type input is detected with a | |
| // non-blank value. You can use this hook to implement a handler that | |
| // will deal with those non-blank file inputs. Returning false will | |
| // disallow standard form submission. | |
| 'ajax:aborted:file' : 'ajaxAbortedFile', |
| var parser = document.createElement('a'); | |
| parser.href = "http://example.com:3000/pathname/?search=test#hash"; | |
| parser.protocol; // => "http:" | |
| parser.host; // => "example.com" | |
| parser.port; // => "3000" | |
| parser.pathname; // => "/pathname/" | |
| parser.search; // => "?search=test" | |
| parser.hash; // => "#hash" |
| require 'sinatra' | |
| get('/') { 'Hello world' } |
| def render_subject(context) | |
| render subject, context | |
| end | |
| def render_content(context) | |
| render content, context | |
| end | |
| private |
| require 'uri' | |
| class IoraBot::Hangout < IoraBot::Observer | |
| def matcher | |
| /^(hangout|standup)(.*)$/mi | |
| end | |
| def handle(message, match_data) | |
| person = message[:user][:name].split(' ')[0] | |
| command = match_data[1] | |
| if command == 'standup' | |
| reply = "All: time for standup: #{link('iora_standup')}" |
| require 'benchmark' | |
| def ifelse | |
| if true | |
| 1 | |
| else | |
| 2 | |
| end | |
| end |
Backbone.js on Rails @ #rcne2011
Nick Gauthier's presentation from Baltimore.rb
| // Set up the events for the form | |
| form | |
| .submit(function() { return form.isValid(settings.validators); }) | |
| // added loading toggle to handle the feedback spinner image (and changed 'beforeSend' to just 'before') | |
| .bind('ajax:before', function() { $("#loading").toggle(); return form.isValid(settings.validators); }) | |
| .bind('ajax:success', function() { $("#loading").toggle(); }) | |
| // Callbacks | |
| .bind('form:validate:after', function(eventData) { clientSideValidations.callbacks.form.after( form, eventData); }) | |
| .bind('form:validate:before', function(eventData) { clientSideValidations.callbacks.form.before(form, eventData); }) |
| class Hour < ActiveRecord::Base | |
| belongs_to :user | |
| validates_with PunchcardValidator #defined in config/initializers/punchclock_validator.rb | |
| validates_presence_of :role, :message => "can't be blank" | |
| validates_associated :user | |
| validates_numericality_of :manual, :allow_nil => true | |
| validates_presence_of :start_time, :if => :punchcard? | |
| validates_presence_of :manual, :if => :manual? | |