Skip to content

Instantly share code, notes, and snippets.

@iamntz
Forked from andySF/gist:3910397
Created October 18, 2012 08:11
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 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