mirror of
https://gitee.com/layui/layui.git
synced 2025-04-30 12:48:00 +08:00
优化 rate 的 id
属性取值优先级及 elem
可同时渲染多个实例
This commit is contained in:
parent
b8e27d6bcd
commit
c9df4095f4
@ -2,12 +2,14 @@
|
|||||||
* rate 评分评星组件
|
* rate 评分评星组件
|
||||||
*/
|
*/
|
||||||
|
|
||||||
layui.define('jquery',function(exports){
|
layui.define(['jquery', 'lay'],function(exports){
|
||||||
"use strict";
|
"use strict";
|
||||||
var $ = layui.jquery
|
|
||||||
|
|
||||||
//外部接口
|
var $ = layui.jquery;
|
||||||
,rate = {
|
var lay = layui.lay;
|
||||||
|
|
||||||
|
// 外部接口
|
||||||
|
var rate = {
|
||||||
config: {}
|
config: {}
|
||||||
,index: layui.rate ? (layui.rate.index + 10000) : 0
|
,index: layui.rate ? (layui.rate.index + 10000) : 0
|
||||||
|
|
||||||
@ -24,7 +26,7 @@ layui.define('jquery',function(exports){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//操作当前实例
|
// 操作当前实例
|
||||||
,thisRate = function(){
|
,thisRate = function(){
|
||||||
var that = this
|
var that = this
|
||||||
,options = that.config;
|
,options = that.config;
|
||||||
@ -62,10 +64,26 @@ layui.define('jquery',function(exports){
|
|||||||
|
|
||||||
//评分渲染
|
//评分渲染
|
||||||
Class.prototype.render = function(){
|
Class.prototype.render = function(){
|
||||||
var that = this
|
var that = this;
|
||||||
,options = that.config
|
var options = that.config;
|
||||||
,style = options.theme ? ('style="color: '+ options.theme + ';"') : '';
|
|
||||||
|
// 若 elem 非唯一,则拆分为多个实例
|
||||||
|
var elem = $(options.elem);
|
||||||
|
if(elem.length > 1){
|
||||||
|
layui.each(elem, function(){
|
||||||
|
rate.render($.extend({}, options, {
|
||||||
|
elem: this
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
return that;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 合并 lay-options 属性上的配置信息
|
||||||
|
$.extend(options, lay.options(elem[0]));
|
||||||
|
|
||||||
|
// 自定义主题
|
||||||
|
var style = options.theme ? ('style="color: '+ options.theme + ';"') : '';
|
||||||
|
|
||||||
options.elem = $(options.elem);
|
options.elem = $(options.elem);
|
||||||
|
|
||||||
//最大值不能大于总长度
|
//最大值不能大于总长度
|
||||||
|
Loading…
Reference in New Issue
Block a user