Last active
August 29, 2015 13:58
-
-
Save JoshCheek/10344466 to your computer and use it in GitHub Desktop.
JS function that returns a function in order to bind an attribute.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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")); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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