Hi Mike,
(I'm pretty sure you'll answer this)

I am using your the form plugin to bind a form for ajax. It contains one or
more upload fields.

The form gets called into my page from an ajax call. The plug-in is then
binded to form.
At his point, the form is used for uploading image files. If the user
submits the form at this point, everything works great.

The user can choose to upload a Quicktime movie file, in which case, I add
another upload field (now 2 are showing). I also remove a few other form
fields using $("#theDiv").html('') that do not apply to uploading movies. I
then rebind the form. The user clicks submit, and the upload begins. The asp
performs properly without error, but the SUCCESS portion of the binding
never fires.

I know there are no errors on the ASP page. No javascript errors are
reported in the console either. The error can be reproduced in both Safari
and FF on the Mac.

I can also make the error occur if I select movie, then switch back to image
uploading (which does work on the first load).

It seems that switching the forms dynamically is causing the problem (event
though I rebind it).

The code is very complicated so I'll try and post it here:


This is the code that switches the form depending on the user's selection:

function chooseFileType(){
var fileType =
document.gallerySettingsForm2.FileType.options[document.gallerySettingsForm2.FileType.selectedIndex].value;

        if (fileType == 1||fileType == 4||fileType == 5){
        ...abreviated...
        }else if(fileType == 2){
        document.gallerySettingsForm2.sizes.value = '0,90,thor|90,0,tver';
        $("#uploadFiles").html('<table><tr><td
valign="top"><label>*File:</label></td><td><input id="file" name="file"
type="file"  class="multi max-1
accept-mov"/></td></tr></table><br><table><tr><td
valign="top"><label>*Thumbnail:</label></td><td><input id="file2"
name="file2" type="file"  class="multi max-1
accept-jpg|gif|png"/></td></tr></table>');
        $("#iptcDiv").html('');
        $("#presentationDiv").html('')
        
        }else{
        document.gallerySettingsForm2.sizes.value = '0,90,thor|90,0,tver';
        $("#uploadFiles").html('<table><tr><td
valign="top"><label>*File:</label></td><td><input id="file" name="file"
type="file"  class="multi max-1
accept-swf|zip"/></td></tr></table><br><table><tr><td
valign="top"><label>*Thumbnail:</label></td><td><input id="file2"
name="file2" type="file"  class="multi max-1
accept-jpg|gif|png"/></td></tr></table>');
        $("#iptcDiv").html('');
        $("#presentationDiv").html('')
        }
        
        $("#galleryEdits").jScrollPane({showArrows:true,scrollbarWidth:15,
scrollbarMargin:0, arrowSize: 16});
        setFormValues('gallerySettingsForm2');
}


This is the form binding code:

function(theForm){
...abreviated....
}else if(theForm == 'gallerySettingsForm2'){

//add multiple file upload ability to file fields with the class="multi"
        $.MultiFile({
                afterFileRemove:function(){
                uploadImageCounter('sub');
                clearFormErrors();
                if (window.UploadImageCount == 1){
                        $("#multiFileWarning").html('');
                }
                
$("#galleryEdits").jScrollPane({showArrows:true,scrollbarWidth:15,
scrollbarMargin:0, arrowSize: 16});
                },
                
          afterFileAppend:function(element,value,master){
                        uploadImageCounter('add');
                        if (window.UploadImageCount == 2){
                        $("#multiFileWarning").html('You are uploading more 
than one file. If you
add a title, description, keywords or alt tag, it will be applied to all the
images that are being uploaded. You may choose to leave these blank and then
update the individual file captions in the Edit/Delete/Sort Media
section.<div>&nbsp;</div>');
                        }
                
$("#galleryEdits").jScrollPane({showArrows:true,scrollbarWidth:15,
scrollbarMargin:0, arrowSize: 16});
                },
                
        onFileAppend:function(element,value,master){
                checkFileUploadRHM('gallerySettingsForm2', element.id, '', 1)
        }
                
         });
  
                var options = { 
                        iframe: true,
                        target:        '#' + var1,   // target element(s) to be 
updated with
server response 
                        beforeSubmit:  showRequest,  // pre-submit callback 
                        success: function(data) {
                                        showResponse();
                                        //load empty html page into the 
uploader progress frame
                                        
frames['uploadProgessFrame'].location.href='bar_empty.html';
                                }
                };



$('#' + theForm).unbind('submit').submit(function() { 
        // inside event callbacks 'this' is the DOM element so we first 
        // wrap it in a jQuery object and then invoke ajaxSubmit 
        $(this).ajaxSubmit(options)
                
        // !!! Important !!! 
        // always return false to prevent standard browser submit and page
navigation 
        return false; 
        });
}


Thanks. Please email me directly if you'd like to see the code first hand to
[EMAIL PROTECTED] and I'll respond with the URL (I'd prefer to keep
it private at this point).

Much appreciated!
-- 
View this message in context: 
http://www.nabble.com/Form-plugin-not-binding-properly-tf4379630s15494.html#a12484329
Sent from the JQuery mailing list archive at Nabble.com.

Reply via email to