我使用了用于icheck的测量员is的示例,但是为什么错误消息显示为
$el.find(.).iCheck不是函数
,在调用JQuery函数之前,我检查了icheck和checked库是否已添加到此项目和加载的页面中。
http://surveyjs.org/examples/react/custom-widget-icheck/
import { iCheck } from 'icheck';
var radioGroupWidget = {
name: "icheck",
isFit : function(question) { return question["renderAs"] === 'icheck'; },
isDefaultRender: true,
afterRender: function(question, el) {
var $el = $(el);
var select = function() {
$el.find("input[value=" + question.value + "]").iCheck('check');
}
$el.find('input').iCheck({
checkboxClass: 'iradio_square-blue',
radioClass: 'iradio_square-blue'
});
$el.find('input').on('ifChecked', function(event){
question.value = event.target.value;
});
question.valueChangedCallback = select;
select();
},
willUnmount: function(question, el) {
var $el = $(el);
$el.find('input').iCheck('destroy');
}
}
CustomWidgetCollection.Instance.addCustomWidget(radioGroupWidget);发布于 2018-03-15 11:59:04
现在,您可以使用iCheck自定义小部件对SurveyJS进行开箱即用。
...
<script src="https://unpkg.com/surveyjs-widgets"></script>
...请检查一下示例
发布于 2019-08-17 00:11:31
在我的例子中,不应该将函数放在$(document).ready中--这段代码解决了我的错误:
(function (window, document, $) {
'use strict';
var $html = $('html');
$('input[name="myiCheck"]').on('ifClicked', function (event) {
alert("You clicked " + this.value);
});
})(window, document, jQuery);https://stackoverflow.com/questions/45460286
复制相似问题