jBox的使用

本文介绍了一个名为 jBox 的弹窗组件的使用方法,包括 Notice 提示框、Modal 对话框及 Confirm 确认框的具体配置选项与应用实例。通过 JavaScript 实现丰富的交互效果。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

下载地址:https://github.com/StephanWagner/jBox

Notice

var box = new jBox('Notice', {
            overlay: false,
            color: "green",
            attributes: {
                x: 'left',
                y: 'top'
            },
            autoClose: false,
            content: "正在拉取分类……"
 });

autoClose可以是毫秒时间,false表示显示调用box.close()


Modal

页面

<div id="itemContainer" style="display:none;">弹出层内容</div>

js

productList.editBox = new jBox('Modal', {
	closeButton: 'title',
	title: "编辑商品",
	content: $("#itemContainer"),//页面元素 display:none
	draggable: 'title',//可以拖动
	width: 750,
	height: 260,
	maxWidth: 750,
	maxheight: 260,
	closeOnClick: false,
	ajax: {
		url: '/admin/getitem',
		data: {
			itemid: productId
		},
		dataType: "json",
		type: "POST",
		reload: 'strict',
		setContent: false,
		success: function (response) {
			if (response && response.item) {
				productList._initItem(response.item);
			}
			else {
				productList.editBox.close();
				new jBox('Notice', {
					overlay: false,
					color: "black",
					attributes: {
						x: 'left',
						y: 'top'
					},
					autoClose: 2000,
					content: "商品不存在"
				});

			}
		}
	},
	onclose: function () {
		productList.editBox = null;
	}
}).open();

//显示调用open


Confirm

productList.editBox = new jBox('Confirm', {
	content: $("#itemContainer"),
	adjustTracker: false,
	adjustPosition: false,
	reposition: false,
	draggable: 'title',
	width: productList._eidtBoxSize.width,
	height: productList._eidtBoxSize.height,
	maxWidth: productList._eidtBoxSize.width,
	maxheight: productList._eidtBoxSize.height,
	closeButton: 'title',
	attributes: {              
		x: 'left',
		y: 'top'
	},
	position: {
		x: 'center',
		y: 'center'
	},
	title: '编辑商品',
	closeOnConfirm:false,
	cancelButton: '关闭',
	confirmButton: '保存',
	confirm: function () {
		productList._saveProduct();
	},
	ajax: {
		url: '/admin/getitem',
		data: {
			itemid:productId
		},
		dataType: "json",
		type:"POST",
		reload: 'strict',
		setContent: false,
		success: function (response) {
			if (response && response.result) {
				productList._initProductInfo(response.result);
			}
			else {
				productList.editBox.close();
				new jBox('Notice', {
					overlay: false,
					color: "black",
					attributes: {
						x: 'left',
						y: 'top'
					},
					autoClose: 3000,
					content: "服务器忙,请稍后重试"
				});
			}
		},
		error: function () {
			productList.editBox.close();
			new jBox('Notice', {
				overlay: false,
				color: "black",
				attributes: {
					x: 'left',
					y: 'top'
				},
				autoClose: 3000,
				content: "服务器忙,请稍后重试"
			});
		}
	}
}).open();
//open需要显示调用

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

闪耀星星

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值