Ah, don't you love components with file upload? I'm back!

So I am using the hack that makes components work with file upload. My view 
looks like this:

{{= form}}

<script>
    $("#file-form input.upload").button();  // this uses jquery UI's button 
routine

    {{# hack because jquery.form.js does not properly pass headers}}
    {{if response.flash:}}
        $(".flash").hide().html('{{= XML(response.flash)}}').slideDown();
    {{pass}}
    {{if response.js:}}
        eval('{{= XML(response.js)}}');
    {{pass}}
    {{# NOTE SINGLE QUOTES AROUND response.flash AND response.js ABOVE}}
</script>


response.flash and response.js are one-liners.

At initial load there are no problems. However, after form submission, I do 
a return dict(form=form) and the above myfunction.load gets reloaded. At 
this point, there's an error message in the FireBug console saying:


Uncaught ReferenceError: $ is not defined


and it points to the line $("#file-form input.upload").button();


There's another button that's passed in through the form and a script that 
defines its button behavior, and that also gives the same error message.


Now, according to my research, this error message means that jQuery hasn't 
been loaded. Of course, I did load jQuery way back at the beginning in my 
layout.html file that's essentially being extended here, but under the 
auspices of a load.


Nevertheless, the response.js is getting executed correctly and, on top of 
that, the form does display correctly. So this isn't a killer, but it does 
keep me awake at nights. Can any of you deep thinkers out there tell me 
what's actually going on under the hood that's causing this issue, and how 
to make it go away?

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to