qTip content load fails
How to handle content loading failure in example like this:
qtipTo.qtip({
content: { url: 'EditSchedule'}
action method:
public ActionResult EditSchedule(int? id)
{
if (id.HasValue)
{
var schedule = _fService.GetSingle(id);
if (schedule != null)
{
return View("EditSchedule", schedule);
}else
{
return Content("Unable to load correct data. Maybe the element has been deleted.");
}
开发者_StackOverflow }
So basically that's how it works now, but how can I handle it better? If there is no schedule found, qTip shouldn't even get opened.
I recommend handling this scenario by using the onRender
method and doing an ajax call yourself.
qtipTo.qtip({
api: {
onRender: function () {
var api = this;
$.ajax({
type: 'POST',
url: '/EditSchedule',
success: function (content) {
api.updateContent(content);
}
});
}
}
});
Now you can handle any sort of failure in the success callback.
精彩评论