ember.js - Transition to route's action from Ember object -


i new ember. have existing ember app , need implement functionality in it. have ember object below

`import ember 'ember'`  callservice = ember.object.extend   ... other code here   _updateconnectedleadid: (->     console.log "do here??"      **pass route action here**    ).observes('some_other_here') `export default callservice` 

unfortunately, couldn't put whole code here.

my route looks like

applicationroute = ember.route.extend   actions:     showlead: ->       console.log data       console.log "did here?"       @transitionto('dashboard')  `export default applicationroute` 

i tried using @send('showlead'), @sendaction('showlead') in method no luck.

my main intention make transition once console.log "do here??" displayed. not sure if on right way here.

i tried using @transitionto('dashboard') , @transitiontorote('dashboard') directly throws me errors.

i have been stuck day on , clueless.

i'll grateful guidance , help. thanks

you have problem trying trigger route action or trigger transition within ember.object, named call service. code create unclear custom object being created; observer triggered due change object's property update, , on.

nevertheless, tried provide working example you. if open twiddle, see created my-object instance within index.js route , pass model my-component. when click button within my-component.hbs. my-object instances dummyvariable toggled , observer within my-object executes. tricky part here passed index route ownerroute property my-object instance; can trigger index route's dummyaction within my-object.js

ownerroute.send('dummyaction'); 

so related action executes , transition my-route performed. although, believe might solve question; not quite happy design. not think, way ember.objects know routes, actions, controllers, etc. believe proper way observing object's relevant properties within constructs , perform necessary actions own. moreover, might consider creating service instead of object , inject service directly route instead of creating instance of class extending ember.object. if have extend ember.object can inject relevant route, controller, etc instances of particular object class using instance-initializer if need.

anyway, please take @ twiddle , ask more if need to. happy if can.


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -