Picker Modal is a special overlay type which is similar to Picker/Calendar's overlay. Such modal allows to create custom picker overlays with custom content
Picker Modal HTML Layout
Picker Modal layout is pretty simple, just add it somewhere in the end of the <body>
- <body>
- ...
- <!-- Picker Modal Container -->
- <div class="picker-modal">
- <!-- Picker Modal Toolbar, optional -->
- <div class="toolbar">
- <div class="toolbar-inner">
- <div class="left"></div>
- <div class="right">
- <a href="#" class="link close-picker">Done</a>
- </div>
- </div>
- </div>
- <!-- Picker Modal Inner -->
- <div class="picker-modal-inner">
- <!-- Picker content -->
- <div class="content-block">
- <p>Integer mollis nulla id nibh elementum finibus...</p>
- </div>
- </div>
- </div>
- </body>
Open and Close Picker Modal
From HTML
It is possible to open and close required Picker Modal using special classes and data attributes on links:
-
To open picker we need to add "open-picker" class to any HTML element (prefered to link)
-
To close picker we may add "close-picker" class to any HTML element (prefered to link)
-
If you have more than one picker in app, you need to specify appropriate picker via additional data-picker=".my-picker-modal"attribute on this HTML element
- <body>
- <div class="views">
- <div class="view view-main">
- <div class="pages">
- <div data-page="home" class="page navbar-fixed">
- <div class="navbar">
- <div class="navbar-inner">
- <!-- In data-picker attribute we specify CSS selector of picker we need to open-->
- <div class="left"></div>
- <div class="center">Picker Modal</div>
- <div class="right">
- <a href="#" data-picker=".picker-1" class="link open-picker">Picker</a>
- </div>
- </div>
- </div>
- <div class="page-content">
- <div class="content-block">
- <!-- In data-picker attribute we specify CSS selector of picker we need to open-->
- <p><a href="#" data-picker=".picker-1" class="open-picker">Open Picker </a></p>
- <!-- Link to close picker-->
- <p><a href="#" data-picker=".picker-1" class="close-picker">Close Picker </a></p>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- <!-- Picker -->
- <div class="picker-modal picker-1">
- <div class="toolbar">
- <div class="toolbar-inner">
- <div class="left"></div>
- <div class="right"><a href="#" class="close-picker">Done</a></div>
- </div>
- </div>
- <div class="picker-modal-inner">
- <div class="content-block">
- <h4>Info 1</h4>
- <p>Lorem ipsum dolor...</p>
- </div>
- </div>
- </div>
- </body>
Using JavaScript
We can also open and close Picker Modal with JavaScript, for this we need to look at related App methods:
myApp.pickerModal(picker) - open specified Picker Modal
- picker - HTMLElement or string (with CSS Selector) of Picker to open. Requred
- This method returns Picker's HTMLElement
myApp.closeModal(picker) - close Picker
- picker - HTMLElement or string (with CSS Selector). Optional. If not specified, any opened Picker will be closed
- <body>
- <div class="views">
- <div class="view view-main">
- <div class="pages">
- <div data-page="home" class="page navbar-fixed">
- <div class="navbar">
- <div class="navbar-inner">
- <div class="left"></div>
- <div class="center">Picker Modal</div>
- <div class="right">
- <a href="#" class="link open-info">Info</a>
- </div>
- </div>
- </div>
- <div class="page-content">
- <div class="content-block">
- <p><a href="#" class="open-info">Open Info </a></p>
- <p><a href="#" class="close-info">Close Info </a></p>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- <div class="picker-modal picker-info">
- <div class="toolbar">
- <div class="toolbar-inner">
- <div class="left"></div>
- <div class="right"><a href="#" class="close-picker">Done</a></div>
- </div>
- </div>
- <div class="picker-modal-inner">
- <div class="content-block">
- <h4>Info 1</h4>
- <p>Lorem ipsum dolor ...</p>
- </div>
- </div>
- </div>
- </body>
- var myApp = new Framework7();
- var $$ = Dom7;
- $$('.open-info').on('click', function () {
- myApp.pickerModal('.picker-info')
- });
- $$('.close-info').on('click', function () {
- myApp.closeModal('.picker-info')
- });
Dynamic Picker Modal
Framework7 allows you to create Picker Modals dynamically by passing its HTML to related App methods:
myApp.pickerModal(pickerHTML, removeOnClose) - open Picker with pickerHTML
- pickerHTML - string. HTML string of picker
- removeOnClose - boolean. Optional, by default - true. If true then Picker will be removed from DOM when closed
- This method returns dynamically created Picker's HTMLElement
- <div class="page-content">
- <div class="content-block">
- <p><a href="#" class="create-picker">Create Picker</a></p>
- <p><a href="#" class="close-picker">Close Picker</a></p>
- </div>
- </div>
- var myApp = new Framework7();
- var $$ = Dom7;
- $$('.create-picker').on('click', function () {
- // Check first, if we already have opened picker
- if ($$('.picker-modal.modal-in').length > 0) {
- myApp.closeModal('.picker-modal.modal-in');
- }
- myApp.pickerModal(
- '<div class="picker-modal">' +
- '<div class="toolbar">' +
- '<div class="toolbar-inner">' +
- '<div class="left"></div>' +
- '<div class="right"><a href="#" class="close-picker">Close</a></div>' +
- '</div>' +
- '</div>' +
- '<div class="picker-modal-inner">' +
- '<div class="content-block">' +
- '<p>Lorem ipsum dolor ...</p>' +
- '</div>' +
- '</div>' +
- '</div>'
- )
- });
Picker Events
Picker has the same events as any Modal
open | Picker Element<div class="picker-modal"> | Event will be triggered when Picker starts its opening animation |
opened | Picker Element<div class="picker-modal"> | Event will be triggered after Picker completes its opening animation |
close | Picker Element<div class="picker-modal"> | Event will be triggered when Picker starts its closing animation |
closed | Picker Element<div class="picker-modal"> | Event will be triggered after Picker completes its closing animation |
相关推荐
react-native-modal-datetime-picker, 针对Android和iOS的本地日期时间选取器 react-native-modal-datetime-picker 声明性交叉平台响应本地日期时间选取器。描述这个库公开了一个跨平台接口,用于显示本机日期选取器...
该库公开了一个跨平台的界面,用于显示模式内部的本机日期选择器和时间选择器,从而提供统一的用户和开发人员体验。 在后台,该库使用 。 设置(适用于非EXPO项目) 如果您的项目未使用 ,请使用npm或yarn安装库...
它在Android上使用React Native的Picker ,并在iOS上的Modal使用显示Picker Text 。 安装 npm i react-native-picker-modal --save // OR yarn add react-native-picker-modal 用法 它接收并传递与接收的相同的道具...
Android-react-native-modal-datetime-picker.zip,用于android和ios的react本地日期时间选择器,安卓系统是谷歌在2008年设计和制造的。操作系统主要写在爪哇,C和C 的核心组件。它是在linux内核之上构建的,具有安全...
在uni-app框架中,lb-picker选择器是一种常用的交互组件,用于实现用户在多个选项中进行选择的功能。这个组件是基于JavaScript和Vue.js技术构建的,适用于移动应用开发,特别是那些需要用户输入特定信息如日期、时间...
城市选择插件“city-picker”是一款广泛应用于网页开发中的组件,尤其在处理涉及地理位置和区域选择的场景下显得尤为重要。这款插件基于JavaScript和jQuery库,使得在网页上实现便捷的城市、区县、街道级别的选择变...
<uni-data-picker> 是一个选择类datacom组件。支持多列级联选择。列数没有限制,如果屏幕显示不全,顶部tab区域会左右滚动。 适用于uni-app使用uni-data-picker实现省市区选择器的json数据
`react-native-image-picker` 是一个流行的React Native库,用于在iOS和Android应用中集成图像选择功能,包括从相册选择图片、拍摄照片或录制视频。在这个项目中,我们将深入探讨如何使用`react-native-image-picker...
ElementUI 是一个基于 Vue.js 的开源 UI 组件库,它为开发者提供了丰富的界面元素和设计模式,便于构建美观且响应式的 Web ...在实际开发中,务必参考官方文档以获取最新的 API 和最佳实践,确保代码的稳定性和兼容性。
城市选择插件“city-picker”是一款广泛应用于网页开发中的组件,它主要功能是为用户提供一个交互式的、方便快捷的城市选择界面。在当前信息化社会中,无论是电商网站、地图服务还是各种本地生活应用,都需要这样的...
React-Native-Picker 是一个流行的开源项目,专为React Native平台设计,用于在Android和iOS应用中实现选择器功能。这个项目提供了与原生平台高度兼容的下拉选择器组件,使得开发者能够轻松地在跨平台上创建一致的...
的iOS 安卓 网页 演示版 :party_popper: :party_popper: 安装 $ yarn add react-native-country-picker-modal 基本用法 有关更完整的示例,请打开 import React , { useState } from 'react' import { View , ...
在使用Vue.js框架开发前端界面时,经常会用到Element UI库中的组件来实现复杂的交互功能。Element UI是由饿了么前端团队开源的一套基于Vue 2.0的桌面端组件库,广泛应用于Web开发中。其中,`el-date-picker`组件是一...
Android-react-native-image-crop-picker.zip,iOS/Android图像选择器,支持相机、视频、可配置压缩、多个图像和裁剪,安卓系统是谷歌在2008年设计和制造的。操作系统主要写在爪哇,C和C 的核心组件。它是在linux内核...
总的来说,"android-image-picker"是一个强大且易于使用的开源组件,它极大地简化了Android应用中图片选择的实现过程,帮助开发者节省时间和精力,专注于核心业务逻辑的开发。对于任何需要在Android应用中实现图片...
在网页开发中,日期和时间的选择是常见的交互元素,尤其在表单填写、日历应用等场景下尤为重要。`month-picker`是一款基于jQuery的月份选择器插件,它提供了简洁且美观的界面,让用户能够轻松选择年份和月份,简化了...
**jQuery省市区三级联动插件city-picker详解** 在网页开发中,经常需要实现省市区三级联动的效果,即用户选择一个省份后,相应的城市列表自动更新,再选择城市时,对应的区县列表也会随之变化。这种功能可以提升...
React Native Picker Modal View React本机模块以选择项目选择器模态。 由创建和组件的替代品,具有统一的API和在两种平台上均具有一致的外观。 它是完全可配置的,并包括对文本搜索和字母索引的内置支持。 对于不...
"el-data-picker季度区间选择器"就是这样一个组件,它专为基于ElementUI 2.15.8和Vue.js 2框架的应用设计。这个组件允许用户方便地选取特定时间范围内的季度,提高用户在数据过滤、检索或分析时的效率。 ElementUI...