有没有办法在jQuery Mobile中制作可折叠的元素/集合而不是插入?默认情况下,它将可折叠元素作为插入项.
data-inset="false" 不改变行为.
我有这个代码是别人写的,我想知道,这个jQuery代码选择了什么?这是有效的jQuery代码吗?
var a = $("<h3/>").append($("<a/>", {
href : "/comic/title.html",
class : "comic-link"
}).text("comic-name"));
Run Code Online (Sandbox Code Playgroud)
我从未见过像<h3/>或那样使用HTML标签<a/>.
我正在尝试交叉编译我的maemo环境(GNU)应用程序.在正常编译应用程序时,一切正常,但是当它通过sb2编译时会出现以下警告:
$ sb2 gcc -D_GNU_SORCE -o app -Wall -g -I.......//don't think this is relevant
In file included from wifi_collector_menu.c:50:
wifi_collector_list.c: In function `show_net_apns':
wifi_collector_list.c:777: warning: implicit declaration of function `getline'
Run Code Online (Sandbox Code Playgroud)
我完全混淆为什么会发生这种情况,还有其他的getline在程序中有效,我试图在代码内部和编译器命令中同时定义变量_GNU_SOURCE(不是同时)这是行显然导致警告的代码:
size_t bytesnum = MAX_ESSID;
size_t bytes_read;
char *netname = NULL;
printf("Enter name of selected network:");
bytes_read=getline(&netname,&bytesnum,stdin);//This line
Run Code Online (Sandbox Code Playgroud)
任何帮助将不胜感激,提前谢谢.
我做了一个AJAX调用,它适用于FF和Chrome,但不适用于IE 7-8-9.我正在从我的域中加载JSON文件:
$.ajax({
url: 'js/jquery.desobbcode.json',
dataType: 'json',
cache: false,
success: function(json) {
alert('ok');
},
error: function(xhr, errorString, exception) {
alert("xhr.status="+xhr.status+" error="+errorString+" exception="+exception);
}
});
Run Code Online (Sandbox Code Playgroud)
我也尝试添加,contentType: 'application/json'但我收到相同的输出,这是:
xhr.status=200
error=parsererror
exception=SyntaxError Unterminated string constant
Run Code Online (Sandbox Code Playgroud)
我用JSONLint检查了我的JSON文件,没关系.我检查是否有额外的逗号,内容也被修剪.请参阅我的JSON文件
如果我放dataType: 'text',我收到OK警报,但也有一个调试弹出窗口.
你可以帮帮我吗?问候.
在页面完全加载并且JQM处理了所有ui修改(即列表视图,按钮等)之后,我试图只执行一次JS片段.我确实希望它只在该页面上执行,而不是在后续页面上执行.
我首先尝试的是页面显示
<script>
$('[data-role=page]').live("pageshow", function() {
alert("Ready!");
});
</script>
Run Code Online (Sandbox Code Playgroud)
这有一个问题,即该函数现在附加到页面div,并在每次显示任何后续页面时执行.但是,我只希望执行一次,并且只对包含该JS片段的页面执行.
有没有办法收听pageshow事件,而不实际附加功能.
我能够做到的唯一方法是通过绑定和取消绑定:
<script>
$('[data-role=page]').bind("pageshow.test", testfun);
function testfun() {
alert("Ready!");
$('[data-role=page]').unbind("pageshow.test", testfun);
}
</script>
Run Code Online (Sandbox Code Playgroud)
但有更优雅的方式吗?
我也曾尝试.('refresh') 和.page()无济于事.
文本框更新但不更新滑块位置,因此只要您触摸它,该值就会下降.您可以在此处看到此行为:http://www.webeshoppin.info/st0.html
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Tax</title>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.0-rc.1/jquery.mobile-1.1.0-rc.1.min.css" />
<link href="css/tax.css" rel="stylesheet" type="text/css" />
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.1.0-rc.1/jquery.mobile-1.1.0-rc.1.min.js"></script>
</head>
<body>
<div id="page2" data-role="page" data-add-back-btn="true">
<div data-role="header">
<h4> The Proposed</h4>
<a href="#decisions" data-icon="arrow-r" data-role="button" id="joinls">next</a>
</div><!-- /header -->
<div data-role="content">
<h5>Ducks are Fum</h5>
<div>
<input type="range" min="0" max="150" id="inp1" value="34"/>
</div>
<div>
<a id="but1" href="#" data-role="button" data-mini="true" >but1</a>
</div>
<div id="txthere"></div>
</div>
</div>
</body> …Run Code Online (Sandbox Code Playgroud) 如果用户在智能手机/平板电脑或笔记本电脑上,我想加载不同的脚本.
这是我想要的结果:
笔记本电脑:
<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
Run Code Online (Sandbox Code Playgroud)
智能手机和平板电脑
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
<script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>
Run Code Online (Sandbox Code Playgroud)
我该怎么做?
我有一个多级JSON:
{
"1":{
"name":"PHP",
"slug":"/tag/php",
"type":"Tag"
},
"2":{
"name":"JavaScript",
"slug":"/tag/javascript",
"type":"Tag"
},
"3":{
"name":"X-Browser Shadow",
"slug":"/post/x-browser-shadow",
"type":"Post"
}
}
Run Code Online (Sandbox Code Playgroud)
我想知道解析这个JSON,纯JS或jQuery的最佳方法是什么,我不关心它们中的哪一个.
谢谢 :)
如果我在我的jQuery Mobile应用程序中有一个链接,并使其成为一个按钮.button();.如果我单击文本(按钮的中心),它将不会引发事件"单击".
这是一个例子:http: //jsfiddle.net/9rZHg/
运行此脚本,并尝试瞄准文本.警报弹出窗口不会显示.只有当您单击按钮的其他部分时,它才会起作用.
在设备上进行测试时会发生同样的情况.
有没有一种简单的方法来避免这种情况,或者我是否必须<button>在我的应用程序中使用标签?
谢谢
我一直在努力寻找一种方法来更改标题中的按钮而不会丢失格式.我想将带有删除图标的删除按钮更改为带有复选图标的完成按钮.
这是代码的缩短版本:
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.css" />
<script src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
<script src="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.js"></script>
<script type="text/javascript">
function swapButton() {
$('#button').attr('data-icon', 'check').text('Done').trigger('create');
$('#header').trigger('create');
}
</script>
</head>
<body>
<div data-role="page">
<div data-role="header" data-position="fixed" id="header">
<a data-icon="delete" id="button" onclick="swapButton()">Delete</a>
<h1>Test Page</h1>
</div>
<div data-role="content">
<p>Click on Delete to get Done button</p>
</div>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
这会正确更改按钮的文本,但所有格式都会消失.
我已经尝试使用trigger('create')按钮和标题不起作用,我也尝试过.page()我在其他地方读到的方法,我也试过了.button().
我想不出别的想法.
jquery ×8
javascript ×2
json ×2
ajax ×1
button ×1
c ×1
collapsable ×1
css ×1
getline ×1
gnu ×1
implicit ×1
scratchbox ×1