These are chat archives for canjs/canjs

11th
May 2017
Gira Minus
@gKreator
May 11 2017 00:37
is there a list of dom events for canjs?
Brad Momberger
@bmomberger-bitovi
May 11 2017 00:48
you can look at the can-util/dom/events folder. Each is its own module
CanJS adds inserted, removed, enter, radiochange, and attributes (if you import the modules for each one)
Nitin Pasumarthy
@Nithanaroy
May 11 2017 01:01
Trying to use source maps in Chrome generated by steal build. After build, folder structure and less files are recognized by browser but not the corresponding component JS files and Model folders / files are missing in source folder tree.
Also do not see a special request for .js.map file in Network panel
Gira Minus
@gKreator
May 11 2017 01:51
image.png
@bmomberger-bitovi same issue still :/
@Nithanaroy Yeah I have similar issues
image.png
that returns undefined, but the one under it shows it in the list still
Brad Momberger
@bmomberger-bitovi
May 11 2017 03:23
@gKreator after you splice, it's no longer the same item at index i
Gira Minus
@gKreator
May 11 2017 03:23
but how come it's still in the list?
thats the real problem
4 items, 1 gets spliced, 4 items left
3 items on the view*
Brad Momberger
@bmomberger-bitovi
May 11 2017 03:26
could be a batching thing at that point.
Gira Minus
@gKreator
May 11 2017 03:26
batching thing?
Brad Momberger
@bmomberger-bitovi
May 11 2017 03:26
Yeah, batching the updates.
Gira Minus
@gKreator
May 11 2017 03:26
ohh
yeah the real issue is sending this data with ajax later... item is still there
granted i could set delete: true on each item that gets removed and take care of it manually later
Brad Momberger
@bmomberger-bitovi
May 11 2017 03:28
is this list coming from can-connect
Gira Minus
@gKreator
May 11 2017 03:28
yes it originates from can-connect
Brad Momberger
@bmomberger-bitovi
May 11 2017 03:29
hm. maybe it's a cache copy thing.
Gira Minus
@gKreator
May 11 2017 03:29
image.png

im guessing that

unassigned_route_to_location: {
Type: UnassignedRouteToLocation.List,
Value: UnassignedRouteToLocation.List
}

has something to do with it

image.png
Julian
@pYr0x
May 11 2017 21:20
i have a anchor tag like <a href="#" ($click)="toggleMailGa()"><strong>Prüfbericht an Kunde</strong></a>
but iam using can.route. with that toggle button i changed the route to #
is there a better way of using anchor tags that doesnt change the route?
i didnt want to change the route by clicking the link
Ivo Pinheiro
@ivospinheiro
May 11 2017 21:50
Hi!
A quick question, should the DefineMap methods "get" and "serialize" return the same result?
Here is an example:
https://jsbin.com/rugeboquyo/1/edit?html,js,console
Brad Momberger
@bmomberger-bitovi
May 11 2017 22:06
@ivospinheiro serialize does not return values calculated with getters, by default.
The serialize behavior can be overridden per defined property using serialize: true to serialize as normal, serialize: false to not serialize, and serialize: function() { ... } to custom serialize.
Ivo Pinheiro
@ivospinheiro
May 11 2017 22:09
@bmomberger-bitovi , thanks for your quick reply.
Is there any function that returns an object with all the define properties values of a DefineMap?
Brad Momberger
@bmomberger-bitovi
May 11 2017 22:10
get() with no arguments also includes computed arguments but ignores custom serializers (and does respect serialize: false)
If you want to get all properties and values, you can override DefineMap.prototype.serialize. This should suffice:
serialize: function() {
  return [].reduce.call(Object.getOwnPropertyNames(this), function(ret, key) {
    ret[key] = this[key];
    return ret
 }.bind(this), {});
}
Brad Momberger
@bmomberger-bitovi
May 11 2017 22:16
Obviously, this solution doesn't deep-serialize, so you may need to use this[key].serialize ? this[key].serialize() : this[key] if that's necessary
@pyr0x I've always favored <a href="javascript://">...</a> but the state of the art may have changed
There's also link styling in Bootstrap for buttons, which neatly avoids the issue: <button type="button" class="btn btn-link">...</button>
Brad Momberger
@bmomberger-bitovi
May 11 2017 22:22
The Bootstrap method will alter the line height, though, so if you want them to look more inline, you'll have to set height and line-height.
Julian
@pYr0x
May 11 2017 22:26
ok, i will give them a try, thanks
another question
why do i need a value: {}on the definemap recipent
without i got an error that recipient.mail is not definded
but i thought the promise is resolved and the getter of recipient is linked to the recipientPromise
Brad Momberger
@bmomberger-bitovi
May 11 2017 22:29
Promise resolution is async
So even though recipientPromise resolves, it may not have yet set recipient
Julian
@pYr0x
May 11 2017 22:30
why?
i thought the compute will update the recipient when the promise is resolved
Brad Momberger
@bmomberger-bitovi
May 11 2017 22:31
It does, but recipient.mail is being read before the tick when the recipient resolver is run.
Julian
@pYr0x
May 11 2017 22:32
oh ok
so canjs is batching after a tick?
Brad Momberger
@bmomberger-bitovi
May 11 2017 22:33
maybe, but my money's still on this.recipientPromise.then(resolve); which also waits a tick
Julian
@pYr0x
May 11 2017 22:34
is there a other workaround without setting value: {} ?
Brad Momberger
@bmomberger-bitovi
May 11 2017 22:34
using {{#if recipient}} in the stache is one.
Ivo Pinheiro
@ivospinheiro
May 11 2017 22:35
@bmomberger-bitovi , on CanJS 2 when we call "attr" it returns an object with all the defined properties, even if the serialize was set to false. I was trying to have the same on CanJS 3 having something similar to the old "attr" and the "serialize" function also available.
Brad Momberger
@bmomberger-bitovi
May 11 2017 22:36
Why doesn't .get() work for you?
Julian
@pYr0x
May 11 2017 22:37
thanks @bmomberger-bitovi for you help
Ivo Pinheiro
@ivospinheiro
May 11 2017 22:42
because the get() does not return the properties that has the serialize set to false.
For instance in my examples I was expecting that when calling get() to obtain:
{ id: ..., task: ..., startDate: ...}
Brad Momberger
@bmomberger-bitovi
May 11 2017 23:04
It seems that the behavior of DefineMap and can-map-define diverge on this point, but I have come up with a workaround.
For all of your currently serialize: false properties, change them to serialize: function() {}
The undefined return value will prevent those properties from appearing in the serialize() call, while get() ignores custom serializing functions and performs default serialization on everything.
Ivo Pinheiro
@ivospinheiro
May 11 2017 23:20
@bmomberger-bitovi , your workaround works perfectly.
Thanks
Gira Minus
@gKreator
May 11 2017 23:59
Does canJs have a can-magic module?