MBaas
MBaas

Reputation: 7530

why "ReferenceError: {fn} is not defined"?

I am trying to build a fiddle to test some features of jBox, but when executing the code it complains about askMe not being defined. I do think that it is defined in my script which I also validated with JSLint, so I'm really struggling to get this working.

HTML:

<span onclick="askMe" ">Click me</span>

JS:

var jb;

function askMe() {
  console.log(jb);
  jb.Open({"confirmButton": "new confirm-text here!"});
};


$(function(){

    jb = new jBox(
    "Confirm", {
        "cancel":function() {$(document).trigger("event_no");},
        "cancelButton":"No",
        "confirm":function(){$(document).trigger("event_yes");},
        "confirmButton":"Yes",
        "content":"Do you like this sample?",
        "title":"Your choice, please!"
        }
    );
});

Upvotes: -1

Views: 891

Answers (1)

MBaas
MBaas

Reputation: 7530

I'm just posting this so that the answer can be closed. Rory's comment about the wrapping in jsfiddle really put me on the right track - I had never really understood this feature! (Yeah, embarrassing, I know.) Additionally it had to be a function-call with proper casing, as snowmonkey pointed out.

Upvotes: 0

Related Questions