Laravel 4 - Assign OnChange to Form :: select

Is there a way to assign an OnChange event in the Form :: Select field?

I managed to get around this now, but it is very dirty, and I would like to change it, so all my ajax requests are in one file ...

Anyone else come across this?

Thanks.

+4
source share
2 answers

I managed to fix this guys.

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

Then just an id to assign an onChange event in your JS:

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

Laravel 5 Path:

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

All Articles