This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

Pat Och
Pat Och

hi there,

i would like trigger jquery event keypress on some form fields repeater (the purpose is to block some keys)

I add a correct script who works on any input in the global form but not on the repeater's input

have you some idea to make this working ?

thanks !

Last updated

Pat Och
Pat Och

It seems dynamically added fields by repeater cannot be see by the javascript

Pat Och
Pat Och

available answer here :

http://stackoverflow.com/questions/41117768/october-cms-javascript-event-on-backend-repeater-fields

You stated:-

it seems dynamically added input field by repeater doesn't see by the javascript while it works with others input field of the same form

It is a correct behavior because event binding has been done when page was loaded and you have created new elements afterwards, so event doesn't bound on those elements.

You have to use the technique which is called event delegation. Like:

$(document).on('keypress', 'input', function(e){
      // the code 
  });

Here in this code you can change $(document) to a closest static parent like any div, form etc..


$('form').on('keypress', 'input', function(){
   // code here
});

So, the syntax is:

$(staticParent).on(event, selector, callback); 

Where staticParent is the element which is the parent element when page was loaded. It should not be a dynamically created parent.

Last updated

1-3 of 3

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.