Garden Garden - 25 days ago 10
jQuery Question

Repeater Widget - jQuery detect does not work

The below code works fine with other form element other than "repeater widget" elements in Laravel -> octobercms -> backend ->plugin -> form

$(document).ready(function() {

$('.form-control').on('mouseover',function(){
alert('hi');
});

})


When I hover over normal input fields in the form, I get the alert message. But when I use add repeater elements that contains input field, mouse over them does not trigger alert.

Kindly help.

Regards

Answer

Try using event delegation. There isn't really enough known as to why your approach isn't working unless the elements are added after your code runs such as through ajax

$(document).on('mouseover','.form-control',function(){
     alert('hi');
});