动态警报框与基础 [英] Dynamic Alert Box with Foundation

查看:74
本文介绍了动态警报框与基础的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我应该如何动态地向具有基础的页面添加新警报框?看起来我必须为框插入html标记,然后重新初始化整个页面的基础......这可能不对,可以吗?

How should I go about adding a new alert box dynamically to a page with foundation? It looks like I would have to insert the html markup for the box and then reinitialize foundation for the whole page... that can't be right, can it?

是否有一些简单的方法可以动态添加警告框?

Is there some easy method for adding an alert box dynamically?

我希望api如下: $(#myElement)。foundation('alert',foo 123);

I would expect an api such as: $("#myElement").foundation('alert', "foo 123");

示例:

$.post("/some/url", {some:'data'})
    .fail(function(){
        $("#myElement").foundation('alert', 'Process failed!');
    });


推荐答案

没有API,但你可以这样做:

No API but you can do something like this:

$.post("/some/url", {some:'data'})
.fail(function(){
    var alertBox = '<div data-alert class="alert-box"> Sorry, the request failed.  <a href="#" class="close">&times;</a></div>';
    $("#errorArea").append(alertBox).foundation();
});

这篇关于动态警报框与基础的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆