I have a problem where my order always returns the default value of 1 from the input text. I want to return dynamically based on the data I sent with Ajax, the data is not always one but can be 2, 3, 4, and so on. Can anyone tell me what's wrong with my code? Why always return 1.
This is my controller:
<?php
namespace App\Livewire;
use Livewire\Component;
class Question extends Component
{
public $lecture_number;
public function order()
{
dd($this->lecture_number);
}
}
Here is my HTML input:
<input type="text" value="1" class="form-control" name="lecture_number" wire:click="order" wire:model.fill="lecture_number">
And the last one is my JQuery code:
$(document).on('click', '.lecture-title', function(){
$('input[name=lecture_number]').val($(this).attr('data-lecture-number'));
})