Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

IFrame to upload files, Safari Error #11

Closed
issackelly opened this issue Mar 31, 2010 · 7 comments
Closed

IFrame to upload files, Safari Error #11

issackelly opened this issue Mar 31, 2010 · 7 comments
Labels

Comments

@issackelly
Copy link

This seems to work fine in firefox, I get an error in Chrome:

Uncaught TypeError: Cannot call method 'call' of undefined

And an error in Safari it's a bit more detailed:

TypeError: Result of expression '(jQuery(this).data('form-plugin-onload'))' [null] is not a function.

My Form:

<form method="post"  enctype="multipart/form-data" id="add_photo" action="/add_photo/" id="add_photo"><div style='display:none'><input type='hidden' name='csrfmiddlewaretoken' value='ba7d8cc065e23cd47bdc1b65e5fabac2' /></div>
<table>
    <tr><th><label for="id_title">Caption:</label></th><td><input id="id_title" type="text" name="title" maxlength="255" /></td></tr>
     <tr><th><label for="id_photo">Photo:</label></th><td><input type="file" name="photo" id="id_photo" /><input type="hidden" name="post" value="4" id="id_post" /><input type="hidden" name="owner" value="1" id="id_owner" /><input type="hidden" name="order" value="0" id="id_order" /></td></tr>
   </table>
<input type="submit" name="update" value="Add Picture" />
 </form>

My JS

$("form#add_photo").ajaxForm({
            dataType: 'xml',
            iframe: true,
            beforeSubmit: function(){
                $("form#add_photo").before('<h4 id="loading">Please Wait, Loading</h4>')
            },
            success : function(data,text){
                frick = data
                $("h4#loading").remove()
                $('<li style="background:url('+$(data).find('img:first').attr('src')+') top;display:block;width:300px;height:100px;"><span style="background:rgba(255,255,255,0.7); display:block; height:20%; width:100%"> <input type="radio" name="cover" value=""/><strong>Cover</strong><a href="#move_up">Move Up</a><a href="#move_to_top">Move To Top</a></span></li>').appendTo($('#gallery_sort'));
                $("h3#loading").remove()
            }   
        });
@jzfgo
Copy link

jzfgo commented Apr 8, 2010

Same error here, it seems that only affects WebKit browsers.

@Tomasso
Copy link

Tomasso commented Apr 22, 2010

I get the same with firefox jQuery(this).data("form-plugin-onload") is not a function

@defunkt
Copy link

defunkt commented May 14, 2010

@ovi-zz
Copy link

ovi-zz commented Jun 2, 2010

Set the data before adding the iframe to the DOM. A patch:
diff --git a/jquery.form.js b/jquery.form.js
index be8c0b6..9df8516 100644
--- a/jquery.form.js
+++ b/jquery.form.js
@@ -261,8 +261,8 @@ $.fn.ajaxSubmit = function(options) {
.appendTo(form)[0]);

                                // add iframe to doc and submit the form
-                               $io.appendTo('body');
                                $io.data('form-plugin-onload', cb);
+                               $io.appendTo('body');
                                form.submit();
                        }
                        finally {

@robcolburn
Copy link

confirmed ovi's patch

Though he is using a slightly different version than the the current, you may need to apply manually to Lines 264-265 (version: 2.43 (12-MAR-2010))

@akahn
Copy link

akahn commented Sep 30, 2010

This seems to be fixed in the latest form plugin. Close plz, Mike?

@malsup
Copy link
Collaborator

malsup commented Dec 5, 2010

I believe this is fixed.

This issue was closed.
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants