laravel-admin bind dynamic element with jquery

112 views Asked by At

I have add more fields group for which I am using laravel-admin below code

    protected function form() {
        Admin::script('$("body").on("change", "#has-many-negotiations input[type=\"radio\"]", function() { console.log("s"); });');

            $form->hasMany('negotiations', function (Form\NestedForm $form) {
                $form->radio('comparative_statement', __('Comparative Statement'))->options(['1' => 'yes']);
                $form->file('file')->rules('required');
                $form->text('vendor')->rules('required');
                $form->text('initial')->rules('required');
                $form->text('intermediate_1');
                $form->text('intermediate_2');
                $form->text('intermediate_3');
                $form->text('final_no_regret')->rules('required');
                $form->select('awarded')->options(['No' => 'No', 'Yes' => 'Yes'])->rules('required');
            });
            

        return $form;
    }

Here it is creating radio buttons but I want only one radio button should be active one time

What I have tried.

As you can see I have tried to place a script that should call when any change happens to radio button

Also I have tried to add ->setAttribute('name') in the field but it does not support that

Also I have tried to add another below script but nothing is working

$(document).ready(function () {
    $('body').on('change', '#has-many-negotiations input[type="radio"]', function () {
        console.log("s");
        alert("SDafd");
        $(this).closest('.negotiations-set').find('input[type="radio"]').not(this).prop('checked', false);
    });
});
0

There are 0 answers