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

actionClassName callback is not passed the corresponding model. #10

Open
gtzoganis opened this issue Mar 6, 2013 · 2 comments
Open

Comments

@gtzoganis
Copy link
Contributor

Hi,

Thanks for this component, it is very useful.

I have encountered a case that seems like a bug. In your documentation I read:
"cellClassName (string|callback)

The class name of the cell (td or th). It can be a string or a callback which will be passed the model related to the current row. "

Since there is no specific documentation for an actionClassName that is defined for a view of type ActionCell, I tried to follow the above and assign a function to it that is passed the row model. That did not work.

I have fixed it by editing the source code of Backbone.Datagrid, and replacing the lines
if (this.options.actionClassName) {
a.addClass(this.options.actionClassName);
}
with
if (this.options.actionClassName) {
var actionClassName = this.options.actionClassName;
if (_.isFunction(actionClassName)) {
actionClassName = actionClassName(this.model);
}
a.addClass(actionClassName);
}

It is working ok. I wonder if you think you can include it in a next release of Backbone.Datagrid?

@loicfrering
Copy link
Owner

Well there is indeed a difference between how are managed cellClassName (className for the <td>) and actionClassName (className for the <a>).

You're right, actionClassName should support receiving a callback function too so I'll add this to the next release. In the meantime feel free to open a Pull Request, I would be very pleased to merge it!

gtzoganis pushed a commit to gtzoganis/backbone.datagrid that referenced this issue Aug 10, 2013
gtzoganis added a commit to gtzoganis/backbone.datagrid that referenced this issue Aug 10, 2013
@gtzoganis
Copy link
Contributor Author

pull request created. It is the first time I ever use git, so I hope I haven't done something silly.

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