These are chat archives for canjs/canjs

13th
May 2016
Sunil George
@georgesunil81
May 13 2016 12:32
Hello and Good morning all. I am using CanJS and I want to read values of all the elements on a form when one of the element value changes. I have put a change-event listener on the element that I want to capture change on, but how to read the value of the other elements on the same form. Could someone guide please, or maybe an example out there that helps. Thanks in advance.
Julian
@pYr0x
May 13 2016 15:30
have you a example
that we can rewrite
Sunil George
@georgesunil81
May 13 2016 15:35
@pYr0x so far I am able to read the value of the element I am listening on, but I need to read the values of other elements in the same form. Do you have something that can help me with that?
Any hints on how to do that?
The listener gives me a handle to the element I am listening on.
Julian
@pYr0x
May 13 2016 15:52
sorry dont understand
do you use can.Component?
you can have child components
so you can have a root component <x-form>
and child componentzs
and you can read and listen of all of them
Sunil George
@georgesunil81
May 13 2016 15:55
I am using can.Control not can.Component.
Julian
@pYr0x
May 13 2016 15:56
you should move to can.Component
in can.Component you dont listen on events on the DOM
you listen on viewModel changes
and combine stache tempalte changes with the viewmodel and listen to them
Sunil George
@georgesunil81
May 13 2016 16:01
Oh! And, I thought can.Component are only for making reusable components!
@pYr0x Do you have a link to an example using can.Component and form handling?
Some sample project out there using it maybe?
Also, @pYr0x, does can.Component do everything than can.Control does?
Julian
@pYr0x
May 13 2016 16:12
i check that later... have to go...
Sunil George
@georgesunil81
May 13 2016 16:13
No problem @pYr0x . Thanks for the hint on can.Component. Will check on it too.
Have a great weekend ahead.
Thanks for the help.
Michael Price
@web-mech
May 13 2016 16:15
@georgesunil81 this explains a lot of the core concepts https://canjs.com/guides/Tutorial.html and should provide you with code examples etc.
Sunil George
@georgesunil81
May 13 2016 16:17
Thanks @web-mech . Will go through it today. Thanks for the resource link.
Sunil George
@georgesunil81
May 13 2016 16:28
A quick question, when I did "npm install can", it installed "3.0.0-pre.1" version.
I believe it is not prudent to use the pre versions until they become stable!
Michael Price
@web-mech
May 13 2016 16:29
agreed
npm install can@2.3.23
Sunil George
@georgesunil81
May 13 2016 16:29
My question is how/where to find which is the most stable version for canjs and how to npm install that version.
Oh, ok, you anwered my question there.
How did you know 2.3.23 is the most stable version before the pre though
Ah, it is on the npm page for can
Got it.
Thanks @web-mech for your help with that.
Michael Price
@web-mech
May 13 2016 16:31
np
Sunil George
@georgesunil81
May 13 2016 18:42
Is can-connect available in 2.3.23 or is it a 3+ feature?
One of my teams is using SignalR for realtime updates/server data pushes, etc. I want to try out can-connect if it satisfies the requirement.
Anyone, please let me know...
Kevin Phillips
@phillipskevin
May 13 2016 18:44
You can use it with 2.3
Sunil George
@georgesunil81
May 13 2016 18:45
Thanks @phillipskevin . I believe there needs to be some server side code for realtime updates with can-connect?
I am trying to see if there is any example out there that I can refer to and get onboarded immediately!
Kevin Phillips
@phillipskevin
May 13 2016 18:48
The chat guide uses socket.io
Sunil George
@georgesunil81
May 13 2016 18:59
Thats interesting Kevin @phillipskevin . My situation is that I need my front end view to reflect any data that gets added to the database table in the backend.
Will can-connect help with that?
Kevin Phillips
@phillipskevin
May 13 2016 19:01
using your existing SignalR backend you mean?
Sunil George
@georgesunil81
May 13 2016 19:02
No, I want to avoid using SignalR if at all possible.
Kevin Phillips
@phillipskevin
May 13 2016 19:03
Ok, well whatever server you want to use will need to support realtime connections
usually that’s done with Socket.io if your backend is nodejs
Sunil George
@georgesunil81
May 13 2016 19:04
Okay, I think for my project, the backend is C#.NET
So, you are saying that if I have my backend in nodejs, I could do that with Socket.io and can-connect?
Can-connect in the front end I mean.
Or am I misunderstanding the use of can-connect!?
Kevin Phillips
@phillipskevin
May 13 2016 19:07
If c#.net supports web sockets, you could use can-connect to get the data on the client
I just don’t know enough about c#.net to tell you for sure
Sunil George
@georgesunil81
May 13 2016 19:17
No worries on the c# side. I have folks who can do that. I was wondering what role does can-connect play in the scenario?
For example, I want to develop a chat application that tells both clients when either one is typing up a chat (for example, the user A gets a message whenever user B is doing key presses).
Kevin Phillips
@phillipskevin
May 13 2016 19:20
It will handle updating your lists or items when new events come from the server
so if you have a viewModel that does chatConnection.get({}).then(function(){ ... });
so when the server pushes a change, it will update your view model based on the new data
Sunil George
@georgesunil81
May 13 2016 19:24
That clarifies a lot. Thanks @phillipskevin for your help.