开发者

qTip content load fails

开发者 https://www.devze.com 2023-03-24 17:31 出处:网络
How to handle content loading failure in example like this: qtipTo.qtip({ content: { url: \'EditSchedule\'}

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消