Laravel 4 - Assign OnChange to Form::select

♀尐吖头ヾ 提交于 2019-12-10 16:46:57

问题


Is there a way of assigning an OnChange event to a Form::Select field?

I've managed to get around it at the moment but it's very messy and I'd like to change it so all my ajax requests are within one file...

Anyone else come across this?

Thanks.


回答1:


Managed to fix it guys.

{{ Form::select('name', $options, 'default', array('id' => 'some-id'); }}

Then just the ID to assign the onChange event in your JS:

$(function(){
   $('some-id').change(function(e) {
    //perform AJAX call
   });
});



回答2:


The Laravel 5 way would be:

{!! Form::select( 'name', $options, 'default', array('onchange' => 'doSomething(this)') ) !!}


来源:https://stackoverflow.com/questions/20481319/laravel-4-assign-onchange-to-formselect

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!