javascript - One view for 2 or more pages (backbone.js) -




i have 2 pages. 1 of them dashboard lot of functionality. second page shared dashboard - simple version of first page. dashboard contains view of database (it can contain other info, problem one). can click on filter button , modal window opened. so, simple version of dashboard doesn't have possibility. i'd add it, don't want copy+past code full version of dashboard because code of part 2 thousand lines. i'll add primitive code example:

dashboardview = someanotherview.extend({ initialize: function() {...}, events: {...} // huge objects of jquery events, render: function () {...}, ... // 2k lines of functions events }); 

how can use view on page? tried call function view:

dashboardview.prototype.filterclicked(event); 

but in case event.curenttarget null (it necessary function), tried send "this" context, failed. is there possibility in backbone.js use 1 view 2+ pages without huge copy/past code?

ideally if have simple version , full version of view, should have "base view" (simple one) , full version should extend base view.

it'll like:

var simpledashbard = backbone.view.extend({}); var dashboard = simpledashbard.extend({}); 

in way dashboard have access methods simpledashbard.

your situation sounds need use method extended view in base view. not idea. ideally if it's shared should move base view/extract utility method or service, , of course involve re-writing method reusable





wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -