Wednesday, 15 February 2012

javascript - Pass model to other controller in chaplinjs with a clean url -



javascript - Pass model to other controller in chaplinjs with a clean url -

i'm using brunch-with-chaplinjs boilerplate additional libs (sinon, selenium, chai , mocha). want pass model view, collection-view exact, controller editing.

i can this:

chaplin.utils.redirectto 'editaddress', model:@model

but makes url messy:

localhost:8080/editaddress?model=%5bobject%20object%5d

i can not seem find acceptable way maintain url clean , still pass whole model other controller without refetching model server.

normally utilize chaplin's composer, reusing views.

you can still stack.

create stack in application.coffee there can store items while alter controller.

# hidden other files save, if don't utilize amd, # should place within application object. stack = [] module.exports = class application extends chaplin.application ### programme here ### start: -> # other code here mediator.sethandler 'push', @push mediator.sethandler 'pop', @pop ### # force temporary storage stack. ### push: (item)-> force item ### # pop form temporary storage stack. ### pop: -> homecoming stack.pop()

now can force stack anywhere in code this:

mediator.execute 'push', @model

and retrieve can use:

mediator.execute 'pop'

javascript chaplinjs

No comments:

Post a Comment