Last active
May 2, 2017 08:15
-
-
Save seerahulsingh/baf22938b2b0410b61a3fba56448e32e to your computer and use it in GitHub Desktop.
x-editable-rails automation
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
| $.fn.editable.defaults.mode = 'inline'; | |
| $(".xedit").each(function () { | |
| $(this).editable({ | |
| value: user[$(this).attr('id')], | |
| onblur: 'submit', | |
| showbuttons: false, | |
| source: EmConfig.us_states_short_name.map(function (st) { # array for US state to populate select input | |
| return { value: st, text: st }; | |
| }), | |
| url: '/api/v1/user/update', # | |
| ajaxOptions: { | |
| type: "PUT", | |
| dataType: "json" | |
| }, | |
| params: function (params) { | |
| var userData; | |
| userData = {}; | |
| userData.user = {}; | |
| userData.user[params.name] = params.value; | |
| return userData; | |
| }, | |
| validate: function (value) { | |
| if ($.trim(value) === '') { | |
| return 'This field is required'; | |
| } | |
| }, | |
| send: 'always' | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment