These are chat archives for canjs/canjs

28th
Dec 2015
Justin Meyer
@justinbmeyer
Dec 28 2015 21:11
@cherifGsoul
Mohamed Cherif Bouchelaghem
@cherifGsoul
Dec 28 2015 21:11
:)
Justin Meyer
@justinbmeyer
Dec 28 2015 21:11
so there are 2 forms of attr-less observables
one uses proxies
the other (can-define) would use Object.defineProperty
eventually, I think we should support both ... but Object.defineProperty one could be useful right away
so maybe start with that one?
Mohamed Cherif Bouchelaghem
@cherifGsoul
Dec 28 2015 21:12
ok
sounds great
Justin Meyer
@justinbmeyer
Dec 28 2015 21:14
I think it make sense to be in a different repo
it will work similar to the define plugin
var Person = function(){}
can.define( Person.prototype, {
  first: "*",
  last: "string"
});
but allow you to add direct to a prototype
Justin Meyer
@justinbmeyer
Dec 28 2015 21:28
@cherifGsoul yt?
Mohamed Cherif Bouchelaghem
@cherifGsoul
Dec 28 2015 21:33
the connection is really bad
sorry
Justin Meyer
@justinbmeyer
Dec 28 2015 21:33
np
can you hear me ok?
or see my screen
Justin Meyer
@justinbmeyer
Dec 28 2015 22:12
Thanks to @cherifGsoul, A working-ish version of can-define … .attr-less Observables via Object.defineProperty: https://github.com/canjs/can-define/blob/master/test.js !!!
Adam Tourkow
@atourkow
Dec 28 2015 22:16
I'm following the tutorial and when I use can-href= it puts in the url !#resturants, however, when I'm using my own code, it doesn't have the !# Any idea why?
Justin Meyer
@justinbmeyer
Dec 28 2015 22:19
what do you mean "your own code"?
Mohamed Cherif Bouchelaghem
@cherifGsoul
Dec 28 2015 22:19
Thank you @justinbmeyer for the guidance
Justin Meyer
@justinbmeyer
Dec 28 2015 22:20
@atourkow in 2.3 ... we're replacing can-route with routeUrl: http://canjs.com/docs/can.stache.helpers.routeUrl.html
I'm updating the tutorial ...
Adam Tourkow
@atourkow
Dec 28 2015 22:21
@justinbmeyer Ahh, like pulling parts of the tutorial into a new site and changing some of the code.
Oh! I'm using 2.3.6
Justin Meyer
@justinbmeyer
Dec 28 2015 22:21
in your app, is the href totally empty or missing?
btw, you can call can.route.url programmatically in your console
to see the result
can.route.url({page: "home"})
if the result is the same as routeUrl or can-href ... that means your routing rules aren't right
Adam Tourkow
@atourkow
Dec 28 2015 22:23
no, the href updates but doesn't have the !#
Lemme look at the updates though
your link for 2.3
Justin Meyer
@justinbmeyer
Dec 28 2015 22:24
can-href and routeUrl work the same
the only advantage of routeUrl is that you can pass it the "merge" option
Adam Tourkow
@atourkow
Dec 28 2015 22:28
"This produces (with no pretty routing rules):" What's the pretty routing rules?
Justin Meyer
@justinbmeyer
Dec 28 2015 22:28
can.route(":page")
that registers a pretty routing rule
Adam Tourkow
@atourkow
Dec 28 2015 22:29
When I use {{ routeUrl(undefined,true) }} it shows "/" not "!#" like in the demo.
Justin Meyer
@justinbmeyer
Dec 28 2015 22:29
do you have the pushstate plugin?
loaded?
Adam Tourkow
@atourkow
Dec 28 2015 22:30
I would think so, I clicked them all for custom. (blush)
Justin Meyer
@justinbmeyer
Dec 28 2015 22:30
pushstate sets up pushstate routing
Adam Tourkow
@atourkow
Dec 28 2015 22:30
yeah
Justin Meyer
@justinbmeyer
Dec 28 2015 22:30
which you often need a server to support
don't include that if you want the more simple hashchange routing
(if you are using donejs ... pushstate is the default b/c it comes with a server that supports it)
Adam Tourkow
@atourkow
Dec 28 2015 22:31
nope, just canjs
Looks like I can update nginx to do pushstate
Justin Meyer
@justinbmeyer
Dec 28 2015 22:32
yeah, you need to make sure the same html page that loads the canjs app
is served at every url
Adam Tourkow
@atourkow
Dec 28 2015 22:33
here's a n00b question, so sorry if I'm taking your time. Is there any SEO advantage to using pushstate over hashchange routing?
or, even, does googlebot even read canJS javascript?
Justin Meyer
@justinbmeyer
Dec 28 2015 22:33
googlebot can understand JS now
but they don't really explain what they are doing
they do have a site that lets you see what google sees
so you can make sure it's able to follow
but yes, there is an SEO advantage
I think google dropped support for hash bang #!
Adam Tourkow
@atourkow
Dec 28 2015 22:35
Ok, great to know. Thanks
Justin Meyer
@justinbmeyer
Dec 28 2015 22:35
in general ... it's ok to port an app to hashbang after
this is one of the good features of CanJS ... it's two-way routing
as you never hard-code your urls
Adam Tourkow
@atourkow
Dec 28 2015 22:35
yeah
oh, since I got you, what's the best way to code in a global? like the API domain name
Justin Meyer
@justinbmeyer
Dec 28 2015 22:37
in general ... globals like that are best to avoid
b/c you need to port your app between dev / staging / prod
but, there's lots of ways to get a global to CanJS
and in general ... stick them on the application view model
say your page responds with a bunch of global data embedded in a <script>
<script>
var GLOBALS = {url: "staging.domain.com"}
make sure your app-view-model has that: new AppViewModel({globals: GLOBALS}}
and then it's as easy as writing
href="{{globals.url}}"
if you haven't read through the examples on this page: http://canjs.com/guides/Tutorial.html
they were updated last week
it's worth a look
Adam Tourkow
@atourkow
Dec 28 2015 22:40
Well, it's more for the models: findAll: 'GET '+_api_url+'/station/:station_slug' is what I did
I started looking at the tutorial last week. so, I'll look again :)
Ahh, AppViewModel used to be AppState