for this specific problem i am using Tag-it https://github.com/aehlke/tag-it, a jQuery plug-in that is specific to using tags
I have a list of tags i am using ajax to populate using jQuery ui autocomplete
What I need to do is issue a return false to a specific function BeforeTagAdded when the ajax call returns false, essentially saying the database rejected this tag entry, do not show the tag in the client browser
The developer states that "To clarify, just return false in your callback to reject the tag." that is what i am trying to accomplish
What I have tried in addition to the below code:
- globalizing the result in a variable, then have ajax put the result in, just returns undefined
- using return false and or the combination of event.preventDefault() + stopPropagation()
- using the done or complete methods of the ajax call
The only thing the ajax call returns is a result:true or result:false
in the meantime I will work up a jsfiddle in addition to the below code
beforeTagAdded: function(event, ui) {
if ( !ui.duringInitialization){ //do not fire on page initialization
$.ajax({
url: "handlers/tags.ashx",
dataType: "json",
data: {
idnumber: entity_id,
tag: ui.tagLabel,
operation:"tag"
}
}).done(function(data){
if(data.result == false){
event.preventDefault();
event.stopPropagation();
}
}).complete(function(data){
});
}
},
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…