Skip to content

Instantly share code, notes, and snippets.

@iamntz
Forked from andySF/gist:3910397
Created October 18, 2012 08:11
Show Gist options
  • Save iamntz/3910400 to your computer and use it in GitHub Desktop.
Save iamntz/3910400 to your computer and use it in GitHub Desktop.
$('.typeahead').typeahead({
});
var groupFocusTimer;
$('.group').on('change', function (e) {
if (e.target.value == "") {
return;
}
var _this = this;
groupFocusTimer = window.setTimeout( function(){
$.ajax({
type: 'POST',
data: e.target.value,
dataType: 'json',
url: 'Machines/UpadateGroupForMachine?id=' + $(this).attr('data-id') + '&group=' + e.target.value,
success: function (result) {
$(_this).replaceWith(e.target.value);
}
});
}, 500);
}).on('focus', function(){
window.clearTimeout( groupFocusTimer )
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment