ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Safecracker file field - can't delete a file

April 14, 2011 7:48pm

Subscribe [7]
  • #16 / Apr 19, 2011 10:56pm

    Lisa Wess

    20502 posts

    EE stripped your JS code, so I’m not sure what you removed.  If you remove the entire Matrix call from the form, does the file deletion work?

    Also, are you familiar with Firebug?  That should show you JS errors which might show us exactly where the conflict is.

    Thanks Kelly!

  • #17 / Apr 20, 2011 12:02pm

    kellypacker

    138 posts

    When I just have a plain old file upload field (no other fields) and put my js back in, I get this error:

    Uncaught TypeError: Object function ( selector, context ) {
    // The jQuery object is actually just the init constructor 'enhanced'
    return new jQuery.fn.init( selector, context );
    } has no method ‘ee_filebrowser’

    in this file: ?ACT=25031986&ui=core,widget,mouse,position,draggable,resizable,button,dialog,datepicker&plugin=scrollable,scrollable.navigator,ee_filebrowser,markitup,thickbox&v=1302814371&include_jquery=y

    When I take out my js, I don’t get the error.

    If my js is in or out, the file upload field does not work. When I click on the add file it either does nothing (Chrome) or shoots me to the top (Firefox).

  • #18 / Apr 20, 2011 12:06pm

    kellypacker

    138 posts

    When I have a plain file upload field and a file upload field in a matrix and take out my js, the upload field in the Matrix works perfectly. I can add and delete files. The plain field upload field does not work at all.

    When I put my js back in, the plain field upload field does not work at all. But the field inside the matrix uploads docs, but I can’t delete them (like the original problem) and I get that js error.


    I know this is confusing, trying to be a succinct, accurate and detailed as possible.

  • #19 / Apr 20, 2011 5:04pm

    Sue Crocker

    26054 posts

    Kelly, you’re doing fine. Part of the problem is in trying to re-create your issues locally. Is this a live site?

  • #20 / Apr 21, 2011 2:18pm

    kellypacker

    138 posts

    Yes, I can make you a member for the appropriate member group to test if you like.

  • #21 / Apr 21, 2011 7:06pm

    Brandon Jones

    5500 posts

    Hi Kelly, please check your email.

  • #22 / Apr 22, 2011 2:03am

    jschutt

    452 posts

    Was there a resolution to this issue?  I’m in the same boat at the moment 😊

  • #23 / Apr 22, 2011 1:46pm

    Brandon Jones

    5500 posts

    Hi Jesse,

    We received Kelly’s details and she’s in the queue. We’ll update this post when we have more information.

  • #24 / May 03, 2011 2:56pm

    Kevin Smith

    4784 posts

    Hey Kelly—

    Thanks for your patience while we dug into this one. It looks like the problem here was caused by a jQuery conflict. SafeCracker loads jQuery on its own, and jQuery is loaded again in your page footer. If you take a look at the template edit-section-EL, you’ll see that I replaced your jQuery call with a quick script that checks to see if jQuery is already loaded. It will only load jQuery if it’s not already loaded. Of course, you’ll probably want to pull that code change into {global_js} as I only made the change on an example page.

    For everyone else’s reference, here’s what I did. Instead of calling jQuery directly like usual from script tags, use this. It checks to see if jQuery is already loaded. If not, it loads jQuery. (Put the following code inside script tags, of course.)

    // Only load jQuery if jQuery isn't already defined (loaded)
    if (typeof jQuery == 'undefined') {
           function getScript(url) {
    
                   var script     = document.createElement('script');
                        script.src = url;
    
                   var head = document.getElementsByTagName('head')[0],
                   done = false;
    
                   // Attach handlers for all browsers
                   script.onload = script.onreadystatechange = function() {
    
                           if (!done && (!this.readyState || this.readyState == 'loaded' || this.readyState == 'complete')) {
    
                           done = true;
    
                                   script.onload = script.onreadystatechange = null;
                                   head.removeChild(script);
                           };
                   };
    
                   head.appendChild(script);
           };
    
           getScript('http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js');
    };

    Kelly, let me know if this takes care of things once you get a chance to test it out yourself!

    Kevin

  • #25 / May 03, 2011 3:26pm

    kellypacker

    138 posts

    Hi Kevin,
    Thanks for your work on this and welcome!

    At first glace, shouldn’t this check be done on the safecracker side of things? That way it wouldn’t conflict with existing js in templates?

    Thanks, Kelly

  • #26 / May 03, 2011 5:52pm

    Brandon Jones

    5500 posts

    Hi Kelly,

    I don’t disagree. This is on our radar, and it also wouldn’t hurt to file a feature request for just such a feature. Is everything still working for you at this point?

  • #27 / May 03, 2011 6:00pm

    kellypacker

    138 posts

    Yes, just tested and that fixed it up. Thanks.

  • #28 / May 03, 2011 6:35pm

    Kevin Smith

    4784 posts

    Hey Kelly—

    Thanks for the welcome! And I’m glad to see that this took care of everything. Please don’t hesitate to post again if you need our help.

    Kevin

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases