Skip to content

Instantly share code, notes, and snippets.

@JoshCheek
Last active August 29, 2015 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JoshCheek/10344466 to your computer and use it in GitHub Desktop.
Save JoshCheek/10344466 to your computer and use it in GitHub Desktop.
JS function that returns a function in order to bind an attribute.
function markRowHidden(dataAttribute) {
return function() {
var tr = $(this).closest('tr');
tr.data(dataAttribute, true);
tr.hide();
}
}
$("tr form.type1").on("submit", markRowHidden("attribute1"));
$("tr form.type2").on("submit", markRowHidden("attribute2"));
@theotherzach
Copy link

Re: Dom data vs js state:

If you're mutating, it's state. I like to isolate my application state in tiny js data structures The rest of the app runs as a function of those microscopic objects and the collections fetched from the server.

This article is about react, but doesn't require the use of react: http://facebook.github.io/react/blog/2013/11/05/thinking-in-react.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment