2019独角兽企业重金招聘Python工程师标准>>>

  1. 废话

有一块需求是 有多步表单 点击下一步时触发验证一个范围内的表单,点击上一步或取消,清空表单并返回第一步,点击最后一步提交整个表单的

就找到了这个插件,本来自己写了一个原生的 form+table  点击下一步隐藏所有table 显示当前步骤table的控件,但是老大说丑,嗯哼 就找了这个。

github上的地址,其实已经有 很明确的官方文档了:

https://github.com/VinceG/twitter-bootstrap-wizard

2.可能不是废话

首先 要按顺序引入css文件和js文件

<link rel="stylesheet" type="text/css" media="screen" href="${ctx }/resources/css/bootstrap.min.css" />
<script src="${ctx }/resources/js/jquery-2.2.4.min.js"></script>
<script src="${ctx }/resources/js/bootstrap.min.js"></script>
<script src="${ctx }/resources/js/jquery.bootstrap.wizard.min.js"></script>

先放页面的代码

<div class="group ui-corner-all"style="text-align:center">
<div class="col-md-8 eq-box-md eq-no-panel col-center-block">
<div class="panel"><!-- Classic Form Wizard -->
<!--===================================================-->
<div id="demo-cls-wz">
<!--Nav-->
<ul class="wz-nav-off wz-icon-inline wz-classic">
<li class="col-xs-6 bg-info active">
<a data-toggle="tab" href="#demo-cls-tab1" aria-expanded="true">第一步</a>
</li>
<li class="col-xs-6 bg-info"><a data-toggle="tab" href="#demo-cls-tab2" aria-expanded="false">第二步</a>
</li>
</ul><!--Progress bar-->
<div class="progress progress-xs progress-striped active">
<div class="progress-bar progress-bar-dark" style="width: 50%;"></div>
</div><!--Form-->
<form class="form-horizontal mar-top">
<div class="panel-body"><div class="tab-content"><!--First tab--><div id="demo-cls-tab1" class="tab-pane active in"><div class="form-group"><label class="col-lg-3 control-label">XX代码</label><div class="col-lg-7"><input type="text" class="form-control" name="username" placeholder="Username"></div></div><div class="form-group"><label class="col-lg-3 control-label">企业代码</label><div class="col-lg-7"><input type="email" class="form-control" name="email" placeholder="Email"></div></div><div class="form-group"><label class="col-lg-3 control-label">XX经办人</label><div class="col-lg-7"><input type="text" placeholder="First name" name="firstName" class="form-control"></div></div><div class="form-group"><label class="col-lg-3 control-label">XX经办人联系电话</label><div class="col-lg-7"><input type="text" placeholder="Last name" name="lastName" class="form-control"></div></div><div class="form-group"><label class="col-lg-3 control-label">BB联系人</label><div class="col-lg-7"><input type="text" placeholder="Address" name="address" class="form-control"></div></div><div class="form-group"><label class="col-lg-3 control-label">BB联系电话</label><div class="col-lg-7"><input type="text" placeholder="Address" name="address" class="form-control"></div></div></div><!--Second tab--><div id="demo-cls-tab2" class="tab-pane fade"><div class="form-group"><label class="col-lg-3 control-label">报告资料</label><div class="col-lg-7"><input class="form-control" type="file" name="" id="file"  accept="image/jpg, image/jpeg" onchange="xmTanUploadImg(this)"/><span id="opt"><a href="javascript:preview();" id="preview" >预览</a><input type="button" value="删除" id="delBtn"/></span></div></div></div></div>
</div><!--Footer button-->
<div class="panel-footer text-right"><div class="box-inline"><button type="button" class="previous btn btn-mint disabled">取消</button><button type="button" class="next btn btn-mint" style="display: inline-block;">下一步</button><button type="button" class="btn btn-warning" style="display: none;">上传</button><button type="button" class="finish btn btn-mint" onclick="fb()" style="display: none;">提交</button></div>
</div>
</form>
</div>
<!--===================================================-->
<!-- End Classic Form Wizard -->

再放js初始化的代码

  // =================================================================
$(function(){   $('#demo-cls-wz').bootstrapWizard({tabClass       : 'wz-classic',nextSelector   : '.next',progressBarCurrent: true,previousSelector   : '.previous',onTabClick: function(tab, navigation, index) {return false;},//下一步事件绑定 index 从0开始onNext:function(tab, navigation, index){if(index == 1){//检验表单}},onPrevious:function(){if(confirm("是否放弃申请?")){$("#form")[0].reset();return true;  }else{return false;}},onTabShow: function(tab, navigation, index) {var $total = navigation.find('li').length;var $current = index+1;var $percent = ($current/$total) * 100;var wdt = 100/$total;var lft = wdt*index;$('#demo-cls-wz').find('.progress-bar').css({width:$percent+'%'});// If it's the last tab then hide the last button and show the finish insteadif($current >= $total) {$('#demo-cls-wz').find('.next').hide();$('#demo-cls-wz').find('.finish').show();} else {$('#demo-cls-wz').find('.next').show();}}});
})

最后的效果就是这样子的

============然后勒,官网还提供了一个demo,属性、触发事件和方法=====

http://vinceg.github.io/twitter-bootstrap-wizard/


//官网给的初始化插件的方法
$(document).ready(function() {$('#rootwizard').bootstrapWizard();
});
//初始化时带上初始参数并且绑定事件
$(document).ready(function() {$('#rootwizard').bootstrapWizard({tabClass: 'nav nav-pills',//绑定点击下一步的事件,传入参数为面板tab,标题头navigation,步骤序号index(从0开始)onNext: function(tab, navigation, index) {alert('next');}});
});
//调用方法 此处为展示 第三步的tab
$('#rootwizard').bootstrapWizard('show',3);

偷文档

Options

Key Default Description
withVisible true Find only visible li step elements. Set to `false` if your steps display is hidden.
tabClass 'nav nav-pills' ul navigation class
nextSelector '.wizard li.next' next element selector
previousSelector '.wizard li.previous' previous element selector
firstSelector '.wizard li.first' first element selector
lastSelector '.wizard li.last' last element selector
backSelector '.wizard li.back' back element selector
finishSelector '.wizard li.finish' finish element selector

Events

Key Description
onInit Fired when plugin is initialized
onShow Fired when plugin data is shown
onNext Fired when next button is clicked (return false to disable moving to the next step)
onPrevious Fired when previous button is clicked (return false to disable moving to the previous step)
onFirst Fired when first button is clicked (return false to disable moving to the first step)
onLast Fired when last button is clicked (return false to disable moving to the last step)
onBack Fired when back button is clicked (return false to disable moving backwards in navigation history)
onFinish Fired when finish button is clicked (return value is irrelevant)
onTabChange Fired when a tab is changed (return false to disable moving to that tab and showing its contents)
onTabClick Fired when a tab is clicked (return false to disable moving to that tab and showing its contents)
onTabShow Fired when a tab content is shown (return false to disable showing that tab content)

Methods

Key Parameters Description
next   Moves to the next tab
previous   Moves to the previous tab
first   Jumps to the first tab
last   Jumps to the last tab
back   Moves back in navigation history by jumping to the former tab
finish   "Finishes" the wizard by calling onFinish callback
show zero based index or tab target id Jumps to the specified tab
currentIndex   Returns the zero based index number for the current tab
navigationLength   Returns the number of tabs
enable zero based index Enables a tab, allows a user to click it (removes .disabled if the item has that class)
disable zero based index Disables a tab, disallows a user to click it (adds .disabled to the li element)
display zero based index Displays the li element if it was previously hidden
hide zero based index Hides the li element (will not remove it from the DOM)
remove zero based index, optinal bool remove tab-pane element or not false by default Removes the li element from the DOM if second argument is true will also remove the tab-pane element

转载于:https://my.oschina.net/xlpapapa/blog/1834680

Bootstrap Wizard 多步表单控件相关推荐

  1. Bootstrap 表单控件一(单行输入框input,下拉选择框select ,文本域textarea)

    单行输入框,常见的文本输入框,也就是input的type属性值为text.在Bootstrap中使用input时也必须添加type类型,如果没有指定type类型,将无法得到正确的样式,因为Bootst ...

  2. bootstrap -- css -- 表单控件

    若干css样式 .form-control { display: block;width: 100%;height: 34px;padding: 6px 12px;font-size: 14px;li ...

  3. Bootstrap表单控件的尺寸

    控件的尺寸 在Bootstrap中,可以通过类似.input-lg的类为控件设置高度,类似.col-*的类为控件设置宽度. 1.高度尺寸 一般情况下,控件的默认高度就能满足要求.当然,你也可以为控件添 ...

  4. Bootstrap 表单控件的状态

    在使用过程中,每个控件可能都会有很多状态,通过表单控件的状态,可以给用户或访问者提供一些有用的反馈. Bootstrap提供了 4 种状态,分别是获得焦点状态.无效输入状态.禁用状态.验证状态,并为每 ...

  5. Bootstrap 表单控件的尺寸

    在Bootstrap中,有三种设置控件尺寸的方法,一种是让控件成为块级元素,一种是使用相对尺寸,一种是使用网格尺寸. 1.让控件成为块级元素 如果想让控件像块级元素一样占满容器,就可以为它添加 .in ...

  6. bootstrap 大小 表格,表单控件大小

    前面看到的表单控件都正常的大小.可以通过设置控件的height,line-height,padding和font-size等属性来实现控件的高度设置.不过Bootstrap框架还提供了两个不同的类名, ...

  7. Bootstrap3 表单控件的状态

    控件的状态 在表单的使用过程中,每个控件可能都会有很多状态,通过表单控件的状态,可以给用户或访问者提供一些有用的反馈. Bootstrap为表单控件提供了 4 种状态,分别是获得焦点状态.禁用状态.只 ...

  8. Angular 4.x 自定义表单控件

    当我们打算自定义表单控件前,我们应该先考虑一下以下问题: 是否已经有相同语义的 native (本机) 元素?如:<input type="number"> 如果有,我 ...

  9. 最有范儿的H5制作工具—应用之星之表单控件详解

    H5页面在线制作平台大家应该都很熟悉了,它的出现使招聘.邀请.宣传都变得很精致.最近,应用之星也推出了H5页面制作,这个平台的功能很强大,不仅能做H5页面,还能制作App.其中,平台的表单控件功能具有 ...

最新文章

  1. java实现将汉语转换为拼音
  2. 浅议DAS、NAS、SAN三种存储架构
  3. Java 洛谷 P2141 珠心算测验
  4. Web笔记-通过版本号控制客户端浏览器中的缓存
  5. BZOJ 3450: Tyvj1952 Easy [DP 概率]
  6. java 所有路径算法_经典算法题:二叉树的所有路径
  7. 小红书发布声明:已对站内内容启动全面排查、整改
  8. 微信帐号被封零钱怎么办?微信针对封停帐号的零钱提取出了一个流程
  9. zoj[3868]gcd期望
  10. 阶段3 2.Spring_10.Spring中事务控制_3 作业-基于注解的AOP实现事务控制及问题分析_下...
  11. 具体化和实例化的应用
  12. 原生H5+JS文件上传
  13. 基于ipv6的多分支大学校园网设计与实现
  14. QT目录遍历(QDir)
  15. 二进制编码及浮点数表示
  16. SQL 嵌套 N 层太长太难写怎么办?
  17. Dataframe中添加一列
  18. Spherical Harmonics Lighting in DirectX
  19. C语言 | 九九乘法表
  20. 清朝皇帝年表及1840年后清朝历史事件

热门文章

  1. 查漏补缺!java主要包括哪几种开发平台
  2. 怎么用python爬豆瓣_python爬虫16 | 你,快去试试用多进程的方式重新去爬取豆瓣上的电影...
  3. 手工制作机器人用彩泥_灌浆壶和手工壶的区别,你知道吗?
  4. erp代码matlab,ERP1 Protocol in Matlab - 源码下载|Windows编程|其他小程序|源代码 - 源码中国...
  5. Android单元测试读写文件,xml-如何为android单元测试提供数据文件
  6. 如何提高lstm的预测精度_直线电机点胶机如何提高点胶精度及生产效率?
  7. 基于 props 更新 state
  8. React Fiber 了解一下
  9. 14.最长公共前缀-LeetCode
  10. oracle视图用法,oracle视图大全