问题
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