4

I'm using safecracker and getting this error:

Uncaught ReferenceError: EE is not defined

when using safecracker. I tried this solution:

http://ellislab.com/forums/viewthread/197571/P15

(moving jquery to the footer) and it didn't solve the error. I even loaded the safecracker form via ajax after the rest of the page had loaded, and it didn't solve the issue.

I noticed that if I view source, in the form action parameters there's a whole bunch of jquery UI stuff referenced - I'm not using jquery ui, and the form shouldn't need most of this stuff. On chrome, this worked properly without jquery ui, so I'm not sure what this is all about:

?ACT=10&ui=core,widget,mouse,position,draggable,resizable,button,dialog&plugin=scrollable,scrollable.navigator,markitup,thickbox,toolbox.expose,overlay,tmpl&v=1355863708&use_live_url=y"

I tried including jquery ui but that didn't seem to make a difference. I've attached screenshots of the error - you can feel free to check this out to see what's going on:

http://goo.gl/zTxJA

but keep in mind I'm working on it so it may change. The four screenshots shown below are for two different errors - the first two are when the form is embedded in the template, and I am using my own jquery, and setting include_jquery="no" - the second two are when I use my own jquery, but then load the form via ajax (thus ensuring that the form loads after jquery).

This is my current ee tag for safecracker: {exp:safecracker channel="diy_submissions" return="site/diy_success" include_jquery="no" allow_comments="no" datepicker="no" logged_out_member_id="5" preserve_checkboxes="no"}

I tried removing all the actual form fields and the error still occurs, so I guess you could limit the error to the actual inclusion of safecracker alone, and not to any of the field types used within.

I also put just the form into its own template, allowed it to include jquery, and it loads nothing at all (with no console errors). The source of the code is this:

    <html>
<head><title>Test Form</title></head>
<body>
{exp:safecracker channel="diy_submissions" return="site/diy_success" include_jquery="yes" allow_comments="no" datepicker="no" logged_out_member_id="5" preserve_checkboxes="no"}
<p class="prompt_text">
  Have a recipe, occasion or project idea that uses Carapelli? <br />
  We'd love to showcase it in our gallery. 
</p>
<div class="content_detail_content">
  <nav class="subnav"> 
    <a class="subnav_link collect active" data-ident="collect" data-count="0">Collect</a> 
    <a class="subnav_link assemble" data-ident="assemble" data-count="1">Assemble</a> 
    <a class="subnav_link share lastitem" data-ident="share" data-count="2">Share</a> 
  </nav> 

    <div class="project_content_container">
      <div class="project_text_section collect active">
        <textarea name="submission_collect" value="{submission_collect}">Enter ingredients or supplies needed.</textarea>
      </div>
      <div class="project_text_section assemble">
        <textarea name="submission_assemble" value="{submission_assemble}">Enter project or recipe directions.</textarea>
      </div>
      <div class="project_text_section share">
        <p>
          Perfect! Now give it a name, upload a photo of the finished 
          product and submit your brilliant Carapelli idea! 
        </p>
      </div>
      <div class="project_title share">
        <label for="title">Name</label>
        <input name="title" value="{title}" id="title" type="text" maxlength="100">
      </div>
      <div class="upload_button collect active">
        UPLOAD PHOTO <span class="choose">{field:submission_collect_file}</span> 
      </div>
      <div class="upload_button assemble">
        UPLOAD PHOTO <span class="choose">{field:submission_assemble_file}</span> 
      </div>
      <div class="upload_button share">
        UPLOAD PHOTO <span class="choose">{field:submission_share_file}</span> 
      </div>
      <div class="next_button">
        <span class="next">NEXT STEP</span>
      </div>
      <div class="submit_button" style="display:none;">
        <button name="submit" class="ideas_submit">SUBMIT IDEA<br />
        FOR APPROVAL</button> 
      </div>
    </div>
</div>
{/exp:safecracker}

</body>
</html>

console error when jquery is included in head and not included in EE safecracker tag

area where error occurs

if I load the form via ajax after jquery (my own jquery) loads - I get this error

and it occurs here - at 370

  • Hi mheavers, in order to get a useful answer you probably need to provide some more information, specifically about what you're doing in your template. Is this happening for any safecracker form, or just when using safecracker file as in the forum post you linked? What version of EE are you running etc. The more information you can provide the easier it is for us to help you work out what's going on. – Tom Davies Dec 19 '12 at 21:47
  • I only have one form, which uses safecracker file uploads. I am running the very newest version of EE (2.5.4). – mheavers Dec 19 '12 at 22:52
  • There has to be a line number and a file with this error. Perhaps take a screenshot. We need more information to figure out the issue. It sounds like a class isn't referencing the $this->EE singleton correctly. – Justin Kimbrell Dec 20 '12 at 0:40
  • see updated issue – mheavers Dec 20 '12 at 1:16
  • Are you sure your member channel posting privileges are set up correctly? Also be sure to update to 2.5.4 as their were several bugs fixed in safecracker. – Philip Zaengle Dec 20 '12 at 16:20
1

If you are loading jQuery at the bottom of the page, safecracker will fail because it's adding javascript into the middle of your page before jQuery has loaded.

Make sure that you either:

Load jQuery in your header OR; Use Stash to output your {safecracker_head} tag below your jQuery in your main template.

  • That was my thought too, except you were able to explain it in a lot less words than I would have. – Justin Kimbrell Jan 10 '13 at 21:41
0

The things mentioned in the other answers here may cause this issue. Another cause can be that "Guests" are not allowed to post entries in the channel channel form / safecracker is set up to post to. When loading the page w/o being logged in you will then get "ReferenceError: EE is not defined" .. in the CP, navigating to Member Groups -> Guests and selecting that these are allowed to post to the channel will fix the issue. Be aware of the implications of this change though (guests will be allowed to post entries to that channel).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.