简体   繁体   English

Javascript代码在Phonegap上不起作用

[英]Javascript code doesn't work on phonegap

I read at this link but there's not much discussion or info (of the questioner). 我在此链接上阅读,但没有太多(发问者)的讨论或信息。

I'm writing and android app using phonegap in Eclipse development environment. 我正在Eclipse开发环境中使用phonegap编写Android应用程序。 It's very starter code... so simple that I don't understand why isn't working. 这是非常入门的代码...非常简单,我不明白为什么它不起作用。

I have an index.html with this js function (jquery, jquery-mobile and cordova 2.9 are included) that takes json from remote server and append it to a jquery mobile list: 我有一个带有此js函数(包括jquery,jquery-mobile和cordova 2.9)的index.html,该函数从远程服务器获取json并将其附加到jquery移动列表中:

$(document).bind('deviceready', function() {
  $.getJSON("http://www.remote-server.com/json.php?return=list",function(json) {
    $.each(json,function(i,item){
      $("#list").append('<li><a href="details.html?id=' + item.id + '"><h2>'+item.title+'</h2><p>Start date:'+item.start+'</p></a></li>');
    });
    $("#list").listview('refresh');     
  });
});

Ok, until now all it's Ok. 好吧,到目前为止一切都还好。 But when open details.html, can't execute any js code. 但是当打开details.html时,无法执行任何js代码。 At the beginning I thought It's was problem of includes or something but then I tried simple javascript code setting manually text's tags like: document.getElementById('title').value = "F!&k" 一开始我以为这是个include或其他问题,但后来我尝试手动设置简单的javascript代码来设置文本的标签,例如: document.getElementById('title')。value =“ F!&k”

Do I miss something? 我想念什么吗? config.xml It's standard starter code. config.xml这是标准的入门代码。

Where is the javascript located? JavaScript在哪里?

If you need this javascript to be available at more than one page you should put it in the head of all of your pages. 如果您需要此JavaScript可以在多个页面上使用,则应将其放在所有页面的开头。

If you need this javascript to be available only in a single page, then you should put the javascript inside the 如果您只需要在单个页面中使用此javascript,则应将javascript放在

<div data-role='page'>

that defines the jquery-mobile page where you need it. 定义您需要的jquery-mobile页面。

This is because of the ajax navigation model of jquery mobile. 这是因为jquery mobile的ajax导航模型。

Hope it helps. 希望能帮助到你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM