English 中文(简体)
为什么这个喷射标本的物体没有定义?
原标题:Why is this javascript object undefined?

正如标题所言,我无法解答。 我用茉莉花来尝试确保它被定义, 它不识别文件。 这是代码( 在网络上修补它) :

    Notes.controller = (function ($, dataContext) {
    var notesListSelector = "#notes-list-content";
    var noNotesCachedMsg = "<div>No notes cached</div>";
    var notesListPageId = "notes-list-page";
    var currentNote = null;

    function init() {
        dataContext.init();
        var d = $(document);
        d.bind("pagechange", onPageChange);
    }

    function onPageChange(event, data) {

        var toPageId = data.toPage.attr("id");

        switch (toPageId) {
            case notesListPageId:

                renderNotesList();
                break;
        }
    }

    function renderNotesList() {

        var notesList = dataContext.getNotesList();
        var view = $(notesListSelector);
        view.empty();

        if (notesList.length === 0) {

            $(noNotesCachedMsg).appendTo(view);
        } else {

            var notesCount = notesList.length;
            var note;
            var ul = $("<ul id="notes-list" data-role = "listview"></ul>".appendTo(view);
            for (var i =0; i<notesCount; i++) {
                note = notesList[i];
                $("<li>" + "<a data-url ="index.html#note-editor-page?noteId=" + note.id +
                "" href="index.html#note-editor-page?noteId=" +note.id + "">" + "<div>" +
                note.title + "</div>" + "<div class="list-item-narrative">" + note.narrative
                + "</div>" + "</a>" + "</li>").appendTo(ul);
            }

            ul.listview();
        }


    };

    return {

        init: init
    }

})(jQuery,Notes.dataContext); 

我甚至尝试用开发者提供的源代码来取代所有这一切, 并且它仍然没有定义, 所以这会不会是一个软件配置问题?

谢谢 谢谢

最佳回答

您在此行中丢失了 < code> :

var ul = $("<ul id="notes-list" data-role = "listview"></ul>".appendTo(view);

可能应该:

var ul = $("<ul id="notes-list" data-role = "listview"></ul>").appendTo(view);

同样(虽然不太可能是你出错的原因), 此处不需要这个尾端分号 :

function renderNotesList() {
    ...
};
问题回答

暂无回答




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签