mirror of https://github.com/layui/layui
优化 rate 的 `id` 属性取值优先级及 `elem` 可同时渲染多个实例
parent
b8e27d6bcd
commit
c9df4095f4
|
@ -2,12 +2,14 @@
|
|||
* rate 评分评星组件
|
||||
*/
|
||||
|
||||
layui.define('jquery',function(exports){
|
||||
layui.define(['jquery', 'lay'],function(exports){
|
||||
"use strict";
|
||||
var $ = layui.jquery
|
||||
|
||||
//外部接口
|
||||
,rate = {
|
||||
var $ = layui.jquery;
|
||||
var lay = layui.lay;
|
||||
|
||||
// 外部接口
|
||||
var rate = {
|
||||
config: {}
|
||||
,index: layui.rate ? (layui.rate.index + 10000) : 0
|
||||
|
||||
|
@ -24,7 +26,7 @@ layui.define('jquery',function(exports){
|
|||
}
|
||||
}
|
||||
|
||||
//操作当前实例
|
||||
// 操作当前实例
|
||||
,thisRate = function(){
|
||||
var that = this
|
||||
,options = that.config;
|
||||
|
@ -62,10 +64,26 @@ layui.define('jquery',function(exports){
|
|||
|
||||
//评分渲染
|
||||
Class.prototype.render = function(){
|
||||
var that = this
|
||||
,options = that.config
|
||||
,style = options.theme ? ('style="color: '+ options.theme + ';"') : '';
|
||||
var that = this;
|
||||
var options = that.config;
|
||||
|
||||
// 若 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);
|
||||
|
||||
//最大值不能大于总长度
|
||||
|
|
Loading…
Reference in New Issue