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 form with javascript errors

March 28, 2011 6:25am

Subscribe [10]
  • #1 / Mar 28, 2011 6:25am

    Interfacer

    92 posts

    Hi
    I am using safecracker 2.0 on EE 2.1.3 latest build. I have setup mx google map and encountered javascript issues whilst loading. All the details are in this thread. Long story short: The javascript that loads in the safecracker breaks the google map field type.
    Why am I posting here?
    The same error messages are coming up when I use the safecracker form without any custom fields. That is what firebug spits out:

    syntax error
    [Break on this error] var EE = ,"lang":,"publish":,"user_id"...a082fe6f3321fb60871e7f2aff223d6b1"};}\n
    cassy (line 37)
    syntax error
    [Break on this error] th;e++)a.options[b[e][0]]&&b[e][1].app…rflow")=="hidden")return false;var d=\n
    index….e_url=y (line 11)
    syntax error
    [Break on this error] if (typeof SafeCracker == "undefined" || ! SafeCracker) };}\n
    cassy (line 46)
    EE is not defined
    [Break on this error] <style type="text/css">.hasDatepicker{...;};$.createDatepickerTime();[removed]

    The full source code for this is here


    Any ideas why the javascript error?

    Christian

  • #2 / Mar 28, 2011 7:43am

    Max Lazar

    341 posts

    just to save team time - is not MX Google Map issue, because I asks to delete all parts related to MX Gmap and issue still have a place.

    Interfacer can you check twice that code which you post on pastie, is the same as you have? Because JS in you examples is totally defective.

  • #3 / Mar 28, 2011 4:05pm

    Sue Crocker

    26054 posts

    Thanks for the assist, Max.

    Interfacer, as Max mentioned, if you take MX Google Map out of the equation, do you still have issues?

  • #4 / Mar 28, 2011 9:19pm

    Interfacer

    92 posts

    Hi Sue
    I corrected a path within the fieldtype settings of MX Google Map. That fixed the issue. However taking out MX Google Map, I am still getting a couple of JavaScript errors when I run a simple SafeCracker template. Like so:

    {exp:safecracker channel="cassy"}
                <label for="title">Title</label>
                    <input type="text" name="title" id="title" value="{title}" size="50" maxlength="100">
                    <label for="entry_date">Date</label>
                    <input type="text" name="entry_date" id="entry_date" value="{entry_date}" maxlength="23" size="25" />
                    <input type="submit" name="submit" value="Submit" />
            {/exp:safecracker}

    It turns out that this only happens if I have Debug Preference switched to “0” in CP. If I turn it to “1” They disappear.

    Christian

  • #5 / Mar 29, 2011 4:59pm

    Sue Crocker

    26054 posts

    Hi, Christian. I can’t replicate this with EE2.1.4 beta and with debug set 1. Is this the only thing in your template?

  • #6 / Mar 29, 2011 6:53pm

    narration

    773 posts

    Interfacer, Max, Sue,

    I believe this is a very well-reported problem, showing up again. EE breaks some JavaScript codings when debug is set to 0. In particular, it breaks JSON, which looks like it is one of the problems here. 

    Rob Sanchez, who actually wrote SafeCracker, first reported it, and it is in the Bug Tracker. There is a conversation about whether this is the way the EE debug=0 design should work.

    In the meantime, here’s a Feature Request to get it fixed. A few posts down in the thread, after enough people stumbled on the problem, you’ll find that I published a one-line code patch for EE, which others have used.

      http://ellislab.com/forums/viewthread/177632/

    I’ve proposed a better, more configurable fix along with a speculation as to why Ellis originally made things work in the way that now faults, as it probably made sense at the time.

    Meanwhile, this patch should get the problem out of the way for those who want to use debug 0 for the present.

    It is surely not a fault with Max’s MX Google Map custom field add-on, which I like and use myself—thanks, Max.

    Regards,
    Clive

  • #7 / Mar 29, 2011 8:50pm

    Interfacer

    92 posts

    @narration, thanks for pointing this out to me.

    @Sue, apart from a plain header this is the only markup for the template.

    @Max, no doubt the MX Google Map is a great add-on!

    thanks.

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html >
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
        <meta name="Keywords" content="" />    
        <meta name="Description" content="" />
        <meta name="author" content="" /> 
         <meta name="robots" content="all" /> 
        <title></title>
        
    </head> 
    
        <body>
            {exp:safecracker channel="map"}
                <label for="title">Title</label>
                    <input type="text" name="title" id="title" value="{title}" size="50" maxlength="100">
                    <label for="entry_date">Date</label>
                    <input type="text" name="entry_date" id="entry_date" value="{entry_date}" maxlength="23" size="25" />
                    {field:cf_map}
                    <input type="submit" name="submit" value="Submit" />
            {/exp:safecracker}
        </body>
        
    </html>
  • #8 / Mar 30, 2011 12:23pm

    Sue Crocker

    26054 posts

    Interfacer, is there a reason you have debug set to 0?

  • #9 / Mar 30, 2011 9:07pm

    Interfacer

    92 posts

    No, my config files sets it to 0 as a default. I guess if it causes the issue, I am more than happy to set it to 1.

  • #10 / Mar 31, 2011 9:18am

    Sue Crocker

    26054 posts

    Hi, Interfacer. It’s not the debug level in the config file, but rather the Output and Debugging preference inside of the Control panel. See the attached screen shot.

  • #11 / May 01, 2011 9:09pm

    Sean C. Smith

    3818 posts

    I’ve been having this problem as well. When I set debugging preference to “0: No PHP/SQL error messages generated” My google maps field works. However none of my safecracker code displays, however on a blank template the form fields do display.

    currently the safecracker code is:

    {exp:safecracker channel="gta-attendee" logged_out_member_id="2" return="home" entry_id="1" include_jquery="no"}
                    <input name="attendee-name" type="text" value="Your Name" /> 
                    <input name="attendee-twitter" type="text" value="Twitter Id" /> 
                    <input name="attendee-email" type="text" value="email" /> 
                    <select name="dropdown">
                        <option value="relationship field">Relationship Field</option>
                        <option value="relationship field">related to current event</option>
                    </select>
                    <input type="submit" value="Submit" />
                    this text is inside the safecracker tags
                {/exp:safecracker}

    am puzzled and frustrated by this.

    My thread on the mx google forums is here

  • #12 / May 02, 2011 4:27pm

    Sue Crocker

    26054 posts

    Hi, Sean.

    however on a blank template the form fields do display.

    I’m confused. Are you saying that if you have a brand new template with just the code listed above, it works, but if you add anything having to do with MX Google Map, it has problems?

  • #13 / May 02, 2011 7:00pm

    Sean C. Smith

    3818 posts

    Sue,
    exactly.

  • #14 / May 02, 2011 8:39pm

    Sue Crocker

    26054 posts

    Sean, I have NOT tried this, but it would be easier for you to test than me:

    http://ellislab.com/forums/viewthread/177632/

    This is the thread narration posted a potential fix for this. Any chance you could try it?

  • #15 / May 02, 2011 8:57pm

    Sean C. Smith

    3818 posts

    Sue I did try that and it didn’t work for me, that is when I posted here.

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

ExpressionEngine News!

#eecms, #events, #releases