[英]Yii2 ActiveForm textInput onChange
I've gone through the following man http://www.yiiframework.com/wiki/772/pjax-on-activeform-and-gridview-yii2/ and everything is just fine. 我已经通过以下人员http://www.yiiframework.com/wiki/772/pjax-on-activeform-and-gridview-yii2/ ,一切都很好。 However I'd like to perform Pjax search through my form data WITHOUT click at Submit button.
但是,我想通过我的表单数据执行Pjax搜索,而无需单击“提交”按钮。 Thus I'm trying to use onChange event however I can't find the way to do this.
因此我试图使用onChange事件但是我找不到这样做的方法。 I've found a lot of explanations for dropDownList, but there is no any info about textInput onChange event.
我已经为dropDownList找到了很多解释,但是没有关于textInput onChange事件的任何信息。
Here is a solution to create an instant search input with an delay: 这是一个创建具有延迟的即时搜索输入的解决方案:
Instant search function in Javascript Javascript中的即时搜索功能
Just modifiy your JavaScript-Search-Snippet like this: 只需修改你的JavaScript-Search-Snippet就像这样:
$this->registerJs(
'function instantSearch() {
$.pjax.reload({container:"#countries"}); //Reload GridView
}
var timer;
$("document").ready(function(){
//$("#new_country").on("pjax:end", function() {
$("input").keyUp(function(){
timer && clearTimeout(timer);
timer = setTimeout(instantSearch, 200);
});
});'
);
field($ model,'interview_date') - > textInput() - > widget(DatePicker :: classname(),['pluginOptions'=> ['autoclose'=> true,'format'=>'dd-mm-yyyy ','todayHighlight'=> true,'startDate'=>'今天'],'options'=> ['placeholder'=>'选择日期','onchange'=>'emptyfields(this.value);'] ])?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.