This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-semantic_form_for @presenter.sequence, :action => 'update', :html => {:id => 'edit_narrative'} do |s| | |
-s.semantic_fields_for :unit, :index => nil do |u| | |
-u.inputs do | |
=u.input :narrative_sidebar, :label => false,:as => :text, :input_html => {:class => 'mceEditorNarrative'}, :wrapper_html => { :id => 'narrative_sidebar'} | |
=u.input :narrative, :label => false, :input_html => {:class => 'mceEditorNarrative'}, :as => :text, :wrapper_html => {:id => 'main_narrative'} | |
=u.input :narrative_sidebar_flag, :as => :boolean, :label => "Enable Sidebar:", :wrapper_html => {:class => 'enable_narrative_sidebar'}, :input_html => {:type => "checkbox"} | |
-s.buttons do | |
=s.commit_button :label => 'Update' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This doesn't work: | |
> var data = $.ajax({ url : '/plans.json'}).responseText | |
> undefined | |
// However, if I set data then ask for the responseText, it does. I don't understand why this happens, but I accept it. | |
> var data = $.ajax({ url : '/plans.json'}) | |
> undefined | |
> data.responseText | |
> "[{"plan":{"created_at":"2011-02-21T00:36:29Z","id":1,"updated_at":"2011-02-21T00:36:29Z"}},{"plan":{"created_at":"2011-02- etc etc...... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Hi Tom and Yehuda, | |
I like html. I like handlebars. I don't like what Sproutcore does with handlebars. In the example below, it appears that Sproutcore modifies #each to automatically insert li tags. I find this aggravating. I want Sproutcore to handle my data, DOM updates, etc and let me worry about markup. By their nature, helper methods are not transparent and make it difficult for designers to mark up a page for a SC app. | |
I like using data-attr because they respect MY markup. I can get behind handlebars in SC if it can also respect my markup. | |
Thanks for dialoging about this. I really want to use SC...I just can't get over the view complexity at this point. | |
Thanks! | |
Scott |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Relevant Code::: | |
var Course = Backbone.Model.extend({ | |
url : function(){ | |
var base = 'courses' | |
if (this.isNew()) return base; | |
return base + (base.charAt(base.length-1) == '/'?'' : '/') + this.id; | |
} | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Unit = Honeybee.Model.extend( | |
{ | |
toJSON : function(){ | |
var copy = ko.toJS(this) | |
return {title : copy.title} | |
} | |
,initialize: function(data){ | |
_.extend( this, ko.mapping.fromJS( data, unitMappings, this ) , |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Api::V1::CoursesController < ApplicationController | |
def create | |
current_user ## is nil even though there's a user logged in. How do I access current_user? | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ol data-bind="template :{name : 'show_unit', foreach: unit().units , sortableList: unit().units}"> | |
<span data-bind="text: $item.index"></span> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The backbone router process the url and then calls a function. Here's one of the functions. | |
// NOTE: Unit.fetch, Course.fetch, Unit.fetch methods are all functions which take params, makes an ajax call, then takes the data and creates a new model and returns it. E.g. $.ajax({...}, function(){ new User(data) }) | |
,show_unit: function(username, course_slug, id){ | |
User.fetch(current_user.username, function(user){ | |
App.VMs.current_user(user) | |
Course.fetch(username, course_slug, function(course){ | |
App.VMs.course(course) | |
Unit.fetch(options, function(unit){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Unit.fetch makes an ajax call and passes new Unit(data) to the callback. | |
Unit.fetch(options, function(unit){ | |
addFunctions(unit) | |
App.VMs.unit(unit) | |
} | |
// the console never logs "subscribed" | |
var addFunctions = function(viewModel){ | |
viewModel.units.subscribe(function(){ | |
console.log("subscribed") |