Bootstrap的data-remote用法详解(模态框加载服务器数据,加载另一个页面的数据)

data-remote的作用主要是用来传递URL

1.用<button>按钮作为模态框触发器

    <button id = 'test' data-remote=‘retire/add/dead’> 中data-remote传递的值可在js中用如下方法取出

    var url = $('#test').data('remote');    此时变量url的值就是 'retire/add/dead'

 完整流程代码示例:

 要显示模态框的页面(index.jsp):

<button id="test" data-toggle="modal" data-remote="retire/add/dead">
    添加
</button>

<div class="modal" id="deadAdd" style="display: none">

</div>

  数据来源页(addModel.jsp):

    

<div class="modal-dialog">
    <div class="modal-content" >
        <div class="modal-header">
            <button data-dismiss="modal" class="close">&times;</button>
            <h3 class="modal-title">模态框标题</h3>
        </d
  • 2
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
当然可以,以下是一个简单的登录页面框的例子: ```html <!-- 按钮触发框 --> <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#loginModal">登录</button> <!-- 框 --> <div class="modal fade" id="loginModal" tabindex="-1" role="dialog" aria-labelledby="loginModalLabel" aria-hidden="true"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title" id="loginModalLabel">登录</h5> <button type="button" class="close" data-dismiss="modal" aria-label="关闭"> <span aria-hidden="true">×</span> </button> </div> <div class="modal-body"> <!-- 登录表单 --> <form> <div class="form-group"> <label for="username">用户名</label> <input type="text" class="form-control" id="username" placeholder="请输入用户名"> </div> <div class="form-group"> <label for="password">密码</label> <input type="password" class="form-control" id="password" placeholder="请输入密码"> </div> </form> </div> <div class="modal-footer"> <button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button> <button type="button" class="btn btn-primary">登录</button> </div> </div> </div> </div> ``` 在这个例子中,我们使用了 Bootstrap框组件来创建一个登录页面的弹出框。我们在触发框的按钮上添了 `data-toggle="modal"` 和 `data-target="#loginModal"` 属性,这样点击按钮时就会触发框的显示。同时,我们在框的 HTML 代码中定义了一个 ID 为 `loginModal` 的框,并在按钮的 `data-target` 属性中指定了这个框的 ID。 在框的内容中,我们放置了一个登录表单,包含用户名和密码两个输入框。在框的页眉中,我们添了一个关闭按钮,可以通过点击它来关闭框。 请注意,在这个例子中,我们使用了一些 Bootstrap 的辅助类来添样式,如 `modal`、`modal-dialog`、`modal-content`、`modal-header`、`modal-body`、`modal-footer`、`form-group`、`form-control`、`btn` 等。这些类可以帮助你快速地添样式和布局。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值