⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Custom JS events on form fields



Mrinal Rajpurohit
  • profile picture
  • Member

Posted 14 September 2012 - 17:08 PM

Hi,
I am new to using this amazing auto crud generator. It works amazingly. I want to have something done on keypress event in the addition/updation forms which are auto-generated.

Please guide.
Thanks.

midnigther
  • profile picture
  • Member

Posted 14 September 2012 - 17:34 PM

I don't understand your question, you want use keypress event inside the field forms?

Mrinal Rajpurohit
  • profile picture
  • Member

Posted 16 September 2012 - 05:46 AM

see, when i click on 'add product', a form opens up and in that i have text fields. In those text fields, i want to do something when someone starts typing in. So, want to fire a keypress event when someone presses a key....I guess it can be achieved by some kind of callback but not sure.

midnigther
  • profile picture
  • Member

Posted 16 September 2012 - 18:50 PM

I think the best solution for this problem is put some JS in the view.

So inside the view that will be print the grid you put this code. Alter the #field-name id to the field id you want.


<script type="text/javascript">
$("#field-name").keypress(function() {
alert("Handler for .keypress() called.");
});
</script>