I've got a rails app in which I want to setup my task object with some default values through rails and have knockout.js use those defaults for the observables.
What currently happens is the default from the rails controller is quickly replaced with a blank from the knockout.js observable command.
Here is my rails controller
def new
@task = Task.new
@task.task_date = Time.now
end
My knockout
Task = ->
@name = ko.observable()
@task_date = ko.observable()
My form
= f.text_field :task_date, "data-bind" => "value: name"
= f.text_field :task_date, "data-bind" => "value: task_date"
Do I have to pass JSON from my controller instead of using the default "render :new"?
Can I use the rails defaults at all?
No comments:
Post a Comment