JSFiddle如何在Run上运行代码

时间:2014-10-20 04:01:40

标签: jsfiddle

请参阅此JSFiddle演示。

http://jsfiddle.net/MalcollmS/kLt3pfrc/2/

为什么我的window.onload不运行?

如何运行代码editor.initialise?

马尔科姆

var editor = (function () {
    var editorData = {"Weeks":[{"Days":[{"Date":"\/Date(1417611600000)\/","DayIndex":1,"StartHour":0,"StartMin":0,"FinishHour":0,"FinishMin":0,"LunchHour":0},{"Date":"\/Date(1417698000000)\/","DayIndex":2,"StartHour":0,"StartMin":0,"FinishHour":0,"FinishMin":0,"LunchHour":0},{"Date":"\/Date(1417784400000)\/","DayIndex":3,"StartHour":0,"StartMin":0,"FinishHour":0,"FinishMin":0,"LunchHour":0},{"Date":"\/Date(1417870800000)\/","DayIndex":4,"StartHour":0,"StartMin":0,"FinishHour":0,"FinishMin":0,"LunchHour":0},{"Date":"\/Date(1417957200000)\/","DayIndex":5,"StartHour":0,"StartMin":0,"FinishHour":0,"FinishMin":0,"LunchHour":0},{"Date":"\/Date(1418043600000)\/","DayIndex":6,"StartHour":0,"StartMin":0,"FinishHour":0,"FinishMin":0,"LunchHour":0},{"Date":"\/Date(1418130000000)\/","DayIndex":7,"StartHour":0,"StartMin":0,"FinishHour":0,"FinishMin":0,"LunchHour":0}]}],"NumWeeks":1,"WeekEnding":"\/Date(1418130000000)\/","StartDate":"\/Date(1417611600000)\/"}

    initialise = function (data) {
        //editorData = data;

        $("#starthourselector div").live("click", function () { updateEditor("#starthourselector div", this); });
    };

    function updateEditor(selector, div) {
        alert(selector);
        $(selector).css('background-color','red');
        $(div).css('background-color','white');
        //var idx = $(selector).index(div));
    }

    return {
        initialise: initialise
     };
}());


window.onload = function() {
   alert('hi');
    editor.initialise(null);
}

1 个答案:

答案 0 :(得分:2)

在jsfiddle选项中,单击no wrap head选项,它应该可以正常工作     select no wrap head on the left hand side under on the same dropbox as onLoad     JSFIDDLE