Jump to content
php.lv forumi
  • 0

Backbone loose coupling


qwerty

Question

Nesen sāku darboties ar Backbone un nav skaidra šāda situācija: ja Skatā ir kāda poga, uz kuras nospiežot, lietotāju redirekto uz citu URL (tajā pašā aplikācijā, aiz #), tad kā vislabāk izsaukt attiecīgo Router pathu. Tutoriāļos esmu redzējis divus variantu, kas notiek skata eventā '.click #button'.

 

Pirmais, pa tiešo sazinotes ar Router:

var router = new MyRouter();
router.navigate('doSmtn', {trigger:true});

Otrais, izmantojot kaut kādu papildus eventu sistēmu:

globalEventAggregator.trigger('doSmtn');

Un kaut kur globāli ta sistēma definēta kā:

globalEventAggregator = _.extend({}, Backbone.Events);

Tad nu jautājums vai tā papildus sistēma ir vajadzīga un kādus ieguvumus kas tāds dod?

Edited by qwerty
Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...