【发布时间】:2010-10-12 10:31:30
【问题描述】:
是否可以将 jquery 集成到 Titanium Appcelerator 中,它会正常工作吗? 否则我们无法将 jquery 集成到钛应用加速器中?
有人帮帮我吗?
【问题讨论】:
标签: jquery titanium appcelerator-mobile
是否可以将 jquery 集成到 Titanium Appcelerator 中,它会正常工作吗? 否则我们无法将 jquery 集成到钛应用加速器中?
有人帮帮我吗?
【问题讨论】:
标签: jquery titanium appcelerator-mobile
你到底想做什么?我不确定没有 DOM 是否能正常工作
【讨论】:
你基本上可以使用任何 JS 库 您想要在 WebView 中。外 WebView,基本可以用任何JS 不需要 DOM 的库 (如json2.js等)
(来自here)
【讨论】:
查看以下论坛。您可以通过从中删除 DOM 来使用 Jquery http://developer.appcelerator.com/question/121/use-of-jquery
【讨论】:
首先,您应该创建一个 htlm 文件。您应该在下面看到代码详细信息。有jquery功能。不要忘记上传 jquery-1.9.min.js
<!DOCTYPE html>
<html class="no-js" lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Local URL</title>
<meta name="description" content="">
<meta name="author" content="">
<meta name="viewport" content="width=device-width,initial-scale=1">
<script src="jquery-1.7.1.min.js"></script>
<script>
function firedFromWebView(msg){
$("div").html(msg);
}
//Notice that jQuery works within WebViews
$(document).ready(function(e){
$("a").click(function(e){
//This will fire the custom event "fromWeb" and send the second argument
//as the event's value
Titanium.App.fireEvent("fromWeb",{value:"Fired from webpage"});
});
});
</script>
</head>
<body>
<h1>A Local Webpage</h1>
<a href="javascript:void(0)">Touch to Fire Event</a>
<br/>
<div>Listening...</div>
</body>
</html>
另外一个更新 app.js 上的代码块
var win = Titanium.UI.createWindow({
title:"App to Web View Interaction Through Events",
backgroundColor:"#FFFFFF"
});
var webView = Titanium.UI.createWebView({
url:"html/index.html"
});
var button = Titanium.UI.createButton({
title:"Fire WebView Javascript",
height:48,
width:220,
bottom:12
});
button.addEventListener("click",function(e){
webView.evalJS("firedFromWebView('<strong>Fired!</strong>')");
});
//We can use a custom event listener to fire native code from Javascript pages
//by using Titanium.App.addEventListener
Titanium.App.addEventListener("fromWeb",function(e){
//The data structure and value of e is defined in the
//index.html page
alert(e.value);
});
win.add(webView);
win.add(button);
win.open();
【讨论】: