-
Notifications
You must be signed in to change notification settings - Fork 9
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
Type: class to support some kind of mapping or parse function #12
Comments
Ah, I've had to deal with this situation before a few times. Creating derived properties on the view was what I ended up with: derived: {
widgetStatus: {
deps: ['model.status'],
fn: function () {
return 'widget-' + this.model.status;
}
}
},
bindings: {
widgetStatus: {
type: 'class'
}
} |
+1 on this. Classes namespacing may come handy when working with really generic APIs. |
Views can hold props/derived? I made a AmpersandJS/ampersandjs.com#81 on this undocumented feature. However, I think the proposal still stands. |
+1 on this - Defining a derived property on the view is a decent workaround, but quite often there's something you want to do just to transform the value of the model's property before displaying it, whether it's prefixing a class, formatting a date or a number, etc. It's not ideal to have to define a bunch of I think the option should be named something like |
Closing this as a duplicate of #13 - It will be resolved there. |
I came across an issue where my model has a "status" property that can be "phase1", "phase2" or "phase3" and my classes are equal but prepend "widget-". When I try to use the bindings to change the class of the view element there is no way to prepend, append or parse the class name.
As a work around I had to poison my models with class properties. In my opinion models should not contain any CSS information so i propose the following syntax to make my usage possible without modifying the models:
The text was updated successfully, but these errors were encountered: