brg
brg

Reputation: 3953

Emberjs form, submit function and action helper errors

http://jsfiddle.net/ACzaJ/7/ This fiddle has the following problems:

  1. When you click: 'clear completed button' you will get the error:

    Uncaught Error: assertion failed: Target <Ember.View:ember116> does not have action clearCompletedTodos
    
      And this line generates that error:
     <button {{action clearCompletedTodos  target="Todos.todosController" }} >
          Clear Completed Todos
      </button>
    
  2. I am experimenting with two different submit functions, comment one out per time to try the other:

    2a. When i click 'add' button, when using the first submit function by commenting out the second one, no new todo is added and no error is theown. That is nothing happends.

    2b. When i comment out the first submit function and use the second submit function, clicking add, throws the error below:

    Uncaught TypeError: Cannot call method 'createTodo' of null.
    

How can i make this todo app, run and add and clear todos. Thanks

UPDATE

Question 1 is now resolved by @pauldechov. But question 2a and 2b is unresolved. The jsfiddle link has been updated too. Thanks @pauldechov.

UPDATE 2

The solution provided by Peter here later had issues and Peter resolved the new issues here:

Previously working emberjs1.0-pre form on jsfiddle returns "error": "Please use POST request"

Upvotes: 2

Views: 1426

Answers (1)

Peter Wagenet
Peter Wagenet

Reputation: 5056

First off, it looks like you've given your TodoView an id with spaces in it. This id needs to be a valid HTML id so that will definitely cause some problems. Secondly, the submit function is looking for a value on your instance of TodoFormView. However, the value is defined on your TodoView instance. You need to set up a binding between the two.

I've simplified things a bit by getting rid of TodoView for now and just using a standard TextField. Also, your remaining function needed to be changed to do get('length') with quotes instead of get(length). Additionaly, the checkbox API has changed from some of the older examples, see http://docs.emberjs.com/#doc=Ember.Checkbox.

Here's the updated fiddle: http://jsfiddle.net/wagenet/ACzaJ/8/

Upvotes: 5

Related Questions