views:

82

answers:

1

Hello,

I have to add a Javascript onLoad on a tag : I have a form and I want to disable an input at load.

How can I do this with symfony please ? I have to do this only for forms, so I can't add it in the tag of the layout

A: 

You can use the view.yml to add your js script only on the views containing forms. Like this:

yourViewSuccess:
  javascripts: [yourscript.js]

If you want to use the onload or onready, see this link : http://docs.jquery.com/How_jQuery_Works#Launching_Code_on_Document_Ready

greg0ire
I know this, but after, How can I use <body onLoad='script'> ?
Corum
@Corum: I edited my post, see the link above.
greg0ire
Your link is interesting but, I have try to use $(document).ready but it doesn't work.(I have include jQuery)
Corum
It's ok, your solution works. Thanks a lot
Corum