定制 ingenerator/showgroup 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ingenerator/showgroup

最新稳定版本:v1.0.0

Composer 安装命令:

composer require ingenerator/showgroup

包简介

jQuery plugin to show/hide elements when a field value is selected

关键字:

README 文档

README

This is a simple jQuery plugin to show and hide groups of elements - eg on a form.

Build Status

Dependencies

  • jQuery > 1.*

Installation

Vendor the package into your project however you prefer. Include src/showgroup.js in your project's javascript - usually by compiling it in with any other scripts you're using.

Usage

You can call use showgroup manually:

<div id="container" data-showgroup-container data-showgroup-default="car">
  <div>
    <label>Vehicle Type</label>
    <select id="vehicle">
      <option value="car" selected>Car</option>
      <option value="bike">Bike</option>
      <option value="van">Van</option>
    </select>
  <div data-showgroups="car,van">
    <label>Engine Size</label>
    <input type="text">
  </p>
  <div data-showgroups="car,van,bike">
    <label>Tyre Pressure</label>
    <input type="text">
  </div>
</div>
<script type="text/javascript">
  $('#container').showgroup()>;
  $('#vehicle').on('change', function() {
    $('#container').showgroup($(this).val());
  });
</script>

You could also implement this with the lazy data-api. Note though that you are then responsible for initialising the visibility of the elements, either in javascript or your server-side code:

<div id="container" data-showgroup-container>
  <div>
    <label>Vehicle Type</label>
    <select id="vehicle" data-showgroup-toggle>
      <option value="car">Car</option>
      <option value="bike" selected>Bike</option>
      <option value="van">Van</option>
    </select>
  <div data-showgroups="car,van" style="display: none;">
    <label>Engine Size</label>
    <input type="text">
  </p>
  <div data-showgroups="car,van,bike">
    <label>Tyre Pressure</label>
    <input type="text">
  </div>
</div>

Contributions

Contributions and bugfixes are welcome - just submit a pull request. Please ensure you add new qunit tests to cover your changes.

统计信息

  • 总下载量: 22.3k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 2
  • Forks: 0
  • 开发语言: JavaScript

其他信息

  • 授权协议: BSD
  • 更新时间: 2015-05-05