<li>
<label>Chapter Title</label>
<input type="text" name="chapter[1][title]" />
</li>
<li>
<label>Text</label>
<textarea name="chapter[1][text]" ></textarea>
</li>
<li>
<input type="file" name="image2" id="image2" />
<img id="thumb2" width="100px" height="100px"/>
<input type="hidden" id="image_src2" name="chapter[1][photo]" />
</li>
<li id="caption2" style="display:none;">
<label>Photo Caption</label>
<input type="text" name="chapter[1][photo_caption]" />
</li>
The form fields and javascript code is created dynamically.
var thumb = $('img#thumb2');
new AjaxUpload('image2', {
action: "action",
name: 'userfile',
onSubmit: function(file, extension) {
$('div.preview').addClass('loading');
},
onComplete: function(file, response) {
thumb.load(function(){
$('div.preview').removeClass('loading');
thumb.unbind();
});
thumb.attr('src', response);
$('#image_src2').val(response);
$('#image_src2').live('change',function()
{
$('#caption2').show(); // this does not work
});
}
});
the image is uploading well and the thumbnail is shown but the caption field does not show up and no error is shown.
Try this: