Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using partials #14

Open
alduro opened this issue Jul 7, 2011 · 5 comments
Open

using partials #14

alduro opened this issue Jul 7, 2011 · 5 comments

Comments

@alduro
Copy link

alduro commented Jul 7, 2011

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 ?

@kkaefer
Copy link
Collaborator

kkaefer commented Jul 11, 2011

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

@alduro
Copy link
Author

alduro commented Jul 11, 2011

Thanks kkaefer for your answer.

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

What did I miss where ?
Thanks again.

@kkaefer
Copy link
Collaborator

kkaefer commented Jul 11, 2011

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

@alduro
Copy link
Author

alduro commented Jul 11, 2011

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
Copy link
Author

alduro commented Jul 11, 2011

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants