Created
June 10, 2014 03:17
-
-
Save coleww/0e5d2797c6601d8eb8f3 to your computer and use it in GitHub Desktop.
formify
This file contains hidden or 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
fields = {'#title': 'blah', '.body': 'bla blah', '#date': '1/27/14 etc.', '.option-thing': 'checked'}; | |
submit = '.submit'; | |
var formify = function(fields, submit){ | |
fields.keys.forEach(function(selector){ | |
if(fields[selector] === 'checked' || fields[selector] === 'radio') $(selector).prop('checked', 'checked'); | |
if(fields[selector] === 'click') $(selector).click(); | |
$(selector).val(fields[selector]); | |
}); | |
$(submit).click(); | |
}; | |
//can't do nothing about file inputs | |
//maybe something to handle chosen bros? .chosen-select? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment