These are chat archives for canjs/canjs

19th
Jul 2016
Eben
@eben-roux
Jul 19 2016 04:36
Hello, first time here... anyone able to help me out with the following: http://forums.donejs.com/t/understanding-stache-bindings/363
Kevin Phillips
@phillipskevin
Jul 19 2016 13:58
Hello
I’m not sure I’m understanding your issue @eben-roux
it looks like the email is updating in the second jsbin
I’ll respond back to your forum post
Sunil George
@georgesunil81
Jul 19 2016 15:28
Hello, need help with event-bindings. I am getting a message "WARN: can/view/bindings: ($click) couldn't find method named @assignTask". My stache snippet is as below -
<button type="button" id="assign-task-button" class="btn btn-primary btn-sm btn-block" ($click)='assignTask()'>Assign Task</button>
The assignTask is a function in my controller that renders the above stache.
Anything wrong with the syntax?
The above stache is a partial template though that I am including in the main stache by using {{>path-to-AssignTaskTemplate.stache}}
Kevin Phillips
@phillipskevin
Jul 19 2016 15:30
syntax looks fine
Sunil George
@georgesunil81
Jul 19 2016 15:30
Any idea what could be wrong?
Kevin Phillips
@phillipskevin
Jul 19 2016 15:30
how are you rendering the template?
Sunil George
@georgesunil81
Jul 19 2016 15:31
From the controller (can.control), I am passing the scope object to the main template that includes the above partial.
Kevin Phillips
@phillipskevin
Jul 19 2016 15:31
does that scope object include the assignTask function?
Sunil George
@georgesunil81
Jul 19 2016 15:31
@phillipskevin Thats how I render it.
Hmmm...good question.
How do I put the function on scope?
The below is how I am rendering the main template-
el.html(can.view("app/pages/task/TaskView", scope));
TaskView.stache includes the above mentioned partial.
Kevin Phillips
@phillipskevin
Jul 19 2016 15:33
what is scope?
scope should be an object with that function
Sunil George
@georgesunil81
Jul 19 2016 15:33
var scope = this.scope = new(can.Map.extend({}))();
Kevin Phillips
@phillipskevin
Jul 19 2016 15:34
is that just your convention?
Sunil George
@georgesunil81
Jul 19 2016 15:34
yes
Kevin Phillips
@phillipskevin
Jul 19 2016 15:34
that would be the same as el.html(can.view("app/pages/task/TaskView", {}));
var scope = this.scope = new(can.Map.extend({}))({
    assignTask: this.assignTask
});
Sunil George
@georgesunil81
Jul 19 2016 15:35
Then I put objects on scope, like scope.attr('tasktitle', tasktitle) and such before I pass it to the template.
Oh.
Kevin Phillips
@phillipskevin
Jul 19 2016 15:35
so, do that with assignTask
Sunil George
@georgesunil81
Jul 19 2016 15:35
ok, let me try that.
Yes!!!! That worked. Thanks a bunch @phillipskevin .
Kevin Phillips
@phillipskevin
Jul 19 2016 15:37
sure, no problem
Sunil George
@georgesunil81
Jul 19 2016 15:38
Learning something new everyday. Thanks a lot @phillipskevin. Cant thank you enough for all the help and time you have given me so far.
Happy to be here.