Vtych
Vtych

Reputation: 71

Laravel - disable dropdown using jquery

i have an dropdown which disabled using jquery like this :

$('#group_id_view').prop('disabled', true);

And it working only for view, but what i'm trying to do here is to disable the dropdown for user who had an group_id, so far here is what i have been trying :

$(document).ready( function(){
            if($(this).auth()->user()->group_id){
                    $('#group_id_edit').prop('disabled', true);
                }else{
                    $('#group_id_edit').prop('disabled', false);
                }
        });

And of course it still error, because i don't know how to check the group_id from jquery so that the dropdown will be disabled for users who had an group id and they cannot edit their own group_id, anyone has an solution to this? thank you!.

Upvotes: 0

Views: 207

Answers (1)

amlxv
amlxv

Reputation: 2005

Using Laravel Blade

<select id="group_id_edit" {{ (Auth::user()->group_id) ? 'disabled' : '' }}>

Upvotes: 1

Related Questions