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

Models and IDs for rows #80

Closed
wants to merge 4 commits into from
Closed

Conversation

aramk
Copy link

@aramk aramk commented Jul 13, 2014

Added ID of the underlying model to table rows as a data- attribute. Added the model from the collection to the DOM element using $.data. Together these allow binding events to rows responding clicks. I've got selection of rows working in a separate project using this library and can add that in later on.

aramk added 4 commits May 4, 2014 19:20
…e-table into feature/selectable

# By Amy Slagle (7) and others
# Via Amy Slagle
* 'master' of https://github.com/ecohealthalliance/reactive-table:
  Increase version number.
  Added `sortByValue` explanation to README
  Added sortByValue field option, allowing function-generated fields to be sorted by their original value
  Add additional class for filter event selectors (aslagle#72).
  Increase version number.
  Support for collection-helpers
  Increase version number.
  fix get function to prevent aslagle#11
  safer get function
  Increase version number.
  Cleaned up semicolons and paren spacing
  Minor typo fix
  Added ability to set default sorting field and direction
  Add Turkish to README and reformat language list.
  Increase version number.
  fix Turkish translation
  add Turkish translation
@aslagle
Copy link
Owner

aslagle commented Jul 13, 2014

This is pretty similar to #74. I don't think you need to add the model to the row, since when you use meteor's template.events to bind an event to the row, this will already be set to the model. Is there something you can't do with that?

@aramk
Copy link
Author

aramk commented Jul 14, 2014

If we need to add click events to the rows which run custom logic (e.g. Changing the route to another template based on the ID of the underlying model) is there a way to implement it without storing anything on the dom?

This PR mainly adds the option to extend the table outside of the library using just the row IDs, but another option could be to pass custom helpers which are executed on the rows?

On 14 Jul 2014, at 3:27 am, Amy Slagle [email protected] wrote:

This is pretty similar to #74. I don't think you need to add the model to the row, since when you use meteor's template.events to bind an event to the row, this will already be set to the model. Is there something you can't do with that?


Reply to this email directly or view it on GitHub.

@aslagle
Copy link
Owner

aslagle commented Jul 14, 2014

You can already use the model id (or other attributes) from a click event - like this:

Template.myTemplate.events({
    "click .reactive-table tr" : function (event) {
        Router.go("route", {_id: this._id});
    }
});

@aramk
Copy link
Author

aramk commented Jul 14, 2014

Ah that makes sense. I'll switch over my use cases, but I think you're right and this PR isn't necessary.

@aramk aramk closed this Jul 14, 2014
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

Successfully merging this pull request may close these issues.

2 participants