bones icon indicating copy to clipboard operation
bones copied to clipboard

using partials

Open alduro opened this issue 14 years ago • 5 comments

How should I use partials in bones views ? any example to follow up ? Wiki says: To invoke partials, use this'PartialName'. but where should I call it ?

alduro avatar Jul 07 '11 20:07 alduro

Call this from the template code that requires the partial. See https://github.com/mapbox/tilestream/blob/master/templates/Map._#L2 for an example.

kkaefer avatar Jul 11 '11 13:07 kkaefer

Thanks kkaefer for your answer.

please see this code https://gist.github.com/1076231

What did I miss where ? Thanks again.

alduro avatar Jul 11 '11 16:07 alduro

From the error in that file, the include of the partial seems to happen just fine. However, search_label isn't defined in the template arguments, so it throws an error. Can you paste the contents of /views/Home.server.bones? I can only see the Search view, not the Home view

kkaefer avatar Jul 11 '11 17:07 kkaefer

views/Home.bones

view = Backbone.View.extend({ el: 'view', initialize: function(){ this.render(); } });

Home.server.bones:

views['Home'].prototype.render = function() { this.el = templates.Home(); return this; };

alduro avatar Jul 11 '11 18:07 alduro

well, it works now: views['Home'].prototype.render = function() { var variables = { search_label: "My Search" }; this.el = templates.Home(variables); return this; };

where should I put events for Search template ?

/views/Search.bones view = Backbone.View.extend({ initialize: function(){ this.render(); }, events: { "click input[type=button]": "doSearch"
}, doSearch: function( event ){ // Button clicked, you can access the element that was clicked with event.currentTarget alert( "Search for " + $("#search_input").val() ); } });

or perhaps I should put events into Home.bones instead.

Thanks. I have found this FW + bones-auth + bones-admin the only one that works with models on client and server side and against CouchDB. Quite helpful.

alduro avatar Jul 11 '11 18:07 alduro