These are chat archives for canjs/canjs

18th
Nov 2015
Matthew Phillips
@matthewp
Nov 18 2015 01:15
@pYr0x can you come to the donejs standup tomorrow? Would be good to have you on the core team.
Julian
@pYr0x
Nov 18 2015 01:30
which time?
Matthew Phillips
@matthewp
Nov 18 2015 03:48
@pYr0x sorry, I think it's cancelled tomorrow because Justin is doing a talk in San Francisco
Mihai Fantana
@fantanamihai
Nov 18 2015 09:58

hi guys. I have a project with different synthetic events as seen below:

Case 1:

   can.Control('SimpleSyntheticEvent',{}, {
        'a.syntheticEvent': function(){ } //triggered with $.event.trigger
   })

Case 2:

   can.Control('SyntheticEventOnObject', {}, {
        '{aMap} syntheticEvent': function() { } //triggered with can.event.trigger = can.dispatch = can.event.dispatch OR can.trigger
   })

Is there a common way to trigger events in both cases (e.g. only can.trigger)?
I could not find one.

Julian
@pYr0x
Nov 18 2015 12:04
@matthewp ok, no problem, tomorrow it also suits better for me
Julian
@pYr0x
Nov 18 2015 12:24
@meconcomputer the first one is a dom event, the second one is a can.compute event
you can use the can-click event in den template
*in the
and use one can.Map
that you pass as the context
Mihai Fantana
@fantanamihai
Nov 18 2015 12:27
@pYr0x well not actually.Case 1: is a general event something like after an operation 'operation.terminated' and I used to trigger it with $.event
Case 2. Right is on an object.
Julian
@pYr0x
Nov 18 2015 12:28
right.. is missed that
Mihai Fantana
@fantanamihai
Nov 18 2015 12:28
The idea is that I wanted to have a single "smart triggering function" to not care which is the case
but when I look on the implementation of $.event and can.trigger/can.event, they are using different data storage units for handlers
so I think for the moment Can wants to differentiate between the two
Julian
@pYr0x
Nov 18 2015 12:29
yes think so too
Mihai Fantana
@fantanamihai
Nov 18 2015 12:30
I mean can.event uses a "this.__bindEvents", while $.event uses a "$._data(el)"
in the older JavascriptMVC 3.2 there was a common way to trigger events
and now it is a little bit of "not so cool" to use 2 different ways just to do the same action, but different on context
Julian
@pYr0x
Nov 18 2015 12:32
but in SimpleSyntheticEvent you can trigger the {aMap} syntheticEvent
Mihai Fantana
@fantanamihai
Nov 18 2015 12:33
perhaps @justinbmeyer or @matthewp can bring some light on this
yes, I know there are workarounds, but are they really necessary? :smile:
Julian
@pYr0x
Nov 18 2015 12:34
there a different events
Mihai Fantana
@fantanamihai
Nov 18 2015 12:34
@pYr0x thanks anyway for your help
Julian
@pYr0x
Nov 18 2015 12:34
  1. on an element
  1. on a object
2
Mihai Fantana
@fantanamihai
Nov 18 2015 12:36
case 1 is not on an element per se. Is like a $.event.trigger('a.syntheticElement', window)
Julian
@pYr0x
Nov 18 2015 12:36
using a can component would simplify this
the controll is passt though?
Mihai Fantana
@fantanamihai
Nov 18 2015 12:37
I'm not sure what do you mean by pass through
Julian
@pYr0x
Nov 18 2015 12:37
new SimpleSyntheticEvent(window) ?
Mihai Fantana
@fantanamihai
Nov 18 2015 12:39

ah no. it is more like: new SimpleSyntheticEvent($(someselector)
....
SimpleSyntheticEvent:
makeSomeOperation() -> async call, 'operation.finished' triggered when done ($.event.trigger?)

'operation.finished': ........

that async call is a shared resource between different Controls
Julian
@pYr0x
Nov 18 2015 12:44
so the SimpleSyntheticEvent is bound to an element
why do not tigger an event on a map and that map is in both controlls?
Mihai Fantana
@fantanamihai
Nov 18 2015 12:49
hm... because in the Case 1, I didn't have a map (perhaps only creating one special for this situation)
but I understand the idea
Julian
@pYr0x
Nov 18 2015 12:51
with define plugin
you can create rich behaviour
Mihai Fantana
@fantanamihai
Nov 18 2015 12:51
as a basic conclusion, now Can makes a difference between it's own triggers and jquery's
yes, I use define in other situations
Julian
@pYr0x
Nov 18 2015 12:52
yes
Mihai Fantana
@fantanamihai
Nov 18 2015 12:52
good. thank you for your time @pYr0x
Julian
@pYr0x
Nov 18 2015 12:52
np
Andrei Balmus
@abalmush
Nov 18 2015 15:39
Hi guys, is it possible to get [pageID] from the url using can.rout without “#!" ? Example: (www.mytest.com/us/[pageID])? - it works only if I use www.mytest.com/#!us/[pageID]
Julian
@pYr0x
Nov 18 2015 16:29
you want to parse the window.location
Alexis Abril
@alexisabril
Nov 18 2015 16:47
@abalmush Are you using the pushstate plugin?
if the route is us/:pageid you should be able to do can.route.attr('pageid')
Matthew Phillips
@matthewp
Nov 18 2015 16:52
@pYr0x we are doing a contributor meeting in 40 min, can you attend?
creating the event now
Julian
@pYr0x
Nov 18 2015 16:54
puhh
i will try.. i first must leave the office ;)
you can send me the link and i will attend when i am at home
Matthew Phillips
@matthewp
Nov 18 2015 16:57
sorry for the late notice
Julian
@pYr0x
Nov 18 2015 16:57
no problem
i will hurry
;)
Matthew Phillips
@matthewp
Nov 18 2015 17:01
thanks
i'll send you the link when we start it
Andrei Balmus
@abalmush
Nov 18 2015 17:03
thanks @alexisabril, I tried this, maybe I did something wrong, let me check it again! Thank you a lot!
Matthew Phillips
@matthewp
Nov 18 2015 17:15
Julian
@pYr0x
Nov 18 2015 18:44
@alexisabril that issue you talked about, the promise helper, is that what justin talked about in the meetup?
Alexis Abril
@alexisabril
Nov 18 2015 18:53
@pYr0x I'm not sure actually. I missed the meetup :D