I am using to upload files. Without refreshing the plugin page,
uses hidden iframes to upload. Everything works well except javascript
does not work on the generated code. Here is my code:
& lt; Form id = "image_form" action = "" method = "post" enctype = "multipart / form-data" & gt; & Lt; Input type = "file" id = "image_file" name = "image_file" & gt; & Lt; Br> & Lt; Input type = "submit" value = "upload" & gt; & Lt; / Form & gt; & Lt; Div id = "avatar_wrapper" & gt; & Lt; / Div & gt; This form uploads an image to the server and the server will return some processed images.
& lt; Script type = "text / javascript" & gt; $ (Document) .ready (function () {var option = {success: showResponse, datatype: 'html'}; $ ('# image_form') .jaxform (option); $ ('select_avatar'). Hover (function ) {/ * Just for testing * / Alert ('Hello');});}); Function showResponse (response text, position text, xhr, $ form) {$ ('# avatar_wrapper'). Attachment (feedback text); } & Lt; / Script & gt; There are some images in the response text.
& lt; Img src = "http: //localhost/avatar/0.jpg" class = "select_avatar" option = 0> & Lt; Img src = "http: //localhost/avatar/1.jpg" class = "select_avatar" option = 1> & Lt; Img src = "http: //localhost/avatar/2.jpg" class = "featured option" option = 2 & gt; I wrote this code for testing:
$ ('select_avatar'). Click (function () {/ * Just for testing * / Alert ('Hello');}); It is strange that the click function does not work on these generated codes. Can anyone help me with this? Thank you.
You must use live () , or manually , Click on a click handler on the original element, which is static, and to see event.target which was clicked on. How it works under the live hood, anyways, stay with it :) Note that if you use a new jQuery , Then use instead of () () .
Comments
Post a Comment