到目前为止,我在本网站的其他问题中找不到相同的问题.这是我正在经历的:
我有一个带有UpdatePanel的ASP.NET WebForms应用程序,其中包含一个搜索区域,我有一个ASP:TextBox,我用它来进行jQuery自动完成.
$(document).ready(function() {
$("#tabContainer_tabSearchBreaks_txtSearchName").autocomplete("AutoCompleteEmployee.ashx", { minChars: 3, maxItemsToShow: 10 });
});
Run Code Online (Sandbox Code Playgroud)
这一切工作正常,但如果我点击ASP:按钮并处理搜索区域的一些代码,自动完成javascript将不再有效.
有任何想法吗???
必须有一个解决方案来重置文本框以调用js代码.
[更新 - 更多代码]以下是更新按钮对搜索区域所做的与自动完成代码分开的内容:
try {
int employeeID;
string[] namelst = txtSearchName.Text.Split(new string[] {
" "
}, StringSplitOptions.None);
employeeID = int.Parse(namelst[2].Substring(1, namelst[2].Length - 2));
string name = namelst[0] + " " + namelst[1];
var breaks = bh.ListBreaksForEmployeeByDate(employeeID, DateTime.Parse(txtFromDate.Text), txtToDate.Text.Length > 0 ? DateTime.Parse(txtToDate.Text).AddDays(1).AddSeconds(-1) : DateTime.Today.AddDays(1).AddSeconds(-1));
if (breaks.Count() > 0) {
lblEmployeeTitle.Text = "Breaks for " + name;
gridSearchBreaks.DataSource = breaks;
gridSearchBreaks.DataBind();
}
} catch {} …Run Code Online (Sandbox Code Playgroud) string fileName = "test.zip";
string path = "c:\\temp\\";
string fullPath = path + fileName;
FileInfo file = new FileInfo(fullPath);
Response.Clear();
Response.ClearContent();
Response.ClearHeaders();
Response.Buffer = true;
Response.AppendHeader("content-disposition", "attachment; filename=" + fileName);
Response.AppendHeader("content-length", file.Length.ToString());
Response.ContentType = "application/x-compressed";
Response.TransmitFile(fullPath);
Response.Flush();
Response.End();
Run Code Online (Sandbox Code Playgroud)
实际的zip文件c:\ temp\test.zip是好的,有效的,无论你想要什么.当我导航到目录c:\ temp \并双击test.zip文件时; 它打开了.
我的问题似乎只与下载有关.上面的代码执行没有任何问题.提供了文件下载对话框.我可以选择保存或打开.如果我尝试从对话框中打开文件,或保存它然后打开它.我收到以下对话框消息:
压缩(压缩)文件夹无效或已损坏.
对于Response.ContentType我尝试过:
application/x-compressed application/x-zip-compressed application/x-gzip-compresse application/octet-stream application/zip
正在使用以下代码创建zip文件(我确信由于我能够直接打开创建的文件而正常工作):Ionic.zip
我将多个选定的选项值存储到文本框并使用逗号连接但不想添加最后一个字符串.听到的是我的代码.
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
<select id="garden" name="garden" multiple="multiple">
<option value="1">Flowers</option>
<option value="2">Shrubs</option>
<option value="3">Trees</option>
<option value="4">Bushes</option>
<option value="5">Grass</option>
<option value="6">Dirt</option>
</select>
<input type="text" name="store" id="store" />
<script>
$("#garden").change(function () {
var str = "";
$("select option:selected").each(function () {
str += $(this).val() + ",";
});
$('#store').val(str).attr('rows',str.length) ;
})
.trigger('change');
</script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud) 当我将鼠标悬停在滑块图像上时,如何停止滑块?我使用了以下代码
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js">
</script>
<script type="text/javascript" src="js/jquery.bxslider.min.js"></script>
$('.testimonials-slider').bxSlider({
slideWidth: 800,
minSlides: 1,
maxSlides: 1,
slideMargin: 32,
auto: true,
autoControls: true
});
Run Code Online (Sandbox Code Playgroud) 我是jQuery的新手,并尝试通过示例学习它。在下面的示例中,我尝试使用jQUery Ajax在锚点单击事件上调用servlet。我的页面中有多个锚标签,并且我希望为每个标签调用一个不同的servlet。如果我使用$('#submit1')。click之类的锚标记的ID,如下例所示,它将无法正常工作。但是,如果我将其替换为“ a”,它将为两个锚标记调用相同的servlet
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>AJAX calls using Jquery in Servlet</title>
<script src="http://code.jquery.com/jquery-latest.js">
</script>
<script>
$(document).ready(function() {
$('#submit1').click(function(event) {
event.preventDefault();
var username=$('#user').val();
$.get('ActionServlet',{user:username},function(responseText) {
$('#welcometext').text(responseText);
});
});
});
$(document).ajaxStart(function(){
$('#content_progress').text("Loading...");
});
$(document).ajaxComplete(function(){
$('#content_progress').text("");
});
</script>
</head>
<body>
<form id="form1">
<h1>AJAX Demo using Jquery in JSP and Servlet</h1>
Enter your Name:
<input type="text" id="user"/><br>
<a name="submit1" href="#">View Profile</a>
<a name="submit2" href="#">Course …Run Code Online (Sandbox Code Playgroud) 嗨,经过大量的搜索,我得到了一个检查我的复选框的方法.但我不知道是什么问题.它的VAL()总是返回上.检查时以及取消选中时都会发生这种情况.我想它应该在未选中时返回null.救命
$(document).ready(function(){
$('#ch').change(function(){
alert($(this).val());
});
});
Run Code Online (Sandbox Code Playgroud)
和HTML
<input type="checkbox" id="ch"/> Check it out...
Run Code Online (Sandbox Code Playgroud) 我有一个具有以下结构的文档:
<div id="notice" class="box generalbox">
<p>
This is some text.
</p>
</div>
Run Code Online (Sandbox Code Playgroud)
我想使用jQuery将单词"some"替换为"My".
我该怎么做呢?
我试过了:
$("#notice").text().replace("some", "My");
Run Code Online (Sandbox Code Playgroud)
但那没有用......
更新:感谢您的所有回复.我用这个解决方案让它工作:
$("#notice p").text($("#notice p").text().replace("some", "My"));
Run Code Online (Sandbox Code Playgroud) 我正在研究svg项目我使用d3.js来获得更好的ui,在我的图表中添加了缩放功能,但奇怪的是它的缩放在Google Chrome中不起作用
svg.call(d3.behavior.zoom().scaleExtent([1, 8]).on("zoom", zoom));
function zoom() {
svg.attr("transform", "translate(" + d3.event.translate + ")scale(" + d3.event.scale + ")");
}
Run Code Online (Sandbox Code Playgroud)
而且我想阻止节点拖动的转换,因为节点和窗格同时拖动,所以它看起来非常难看.这是我的小提琴
测试将左侧元素拖动到右侧div
render: function () {
news.fetchMyNews();
for (var i = 1; i <= news.length; i++) {
var newsData = news.get(i);
var newsRow = JST["news/row"](newsData.attributes);
$("#news_tbody").append(newsRow);
if (newsData.is_read == 1) {
this.$('tr').attr("class", "news_read");
} else if (newsData.is_read == 0) {
this.$('tr').attr("class", "news_unread");
}
}
}
Run Code Online (Sandbox Code Playgroud)
在这个代码中,newsData.attributes被很好地检索,我获得了3行渲染的表.
但是,不会检索newsData.is_read值,并且根本没有错误消息,因此行不会出现样式.
新闻是一个集合.
我想知道,这有什么不对吗?我用于测试的JSON文件如下所示:
[{
"id": 1,
"_type": "friends",
"message": "Your friend ...",
"is_read": 1
},
{
"id": 2,
"_type": "friends",
"message": "Your friend ...",
"is_read": 0
},
{
"id": 3,
"_type": "other",
"message": "User ...",
"is_read": …Run Code Online (Sandbox Code Playgroud) 好的,jquery业余警报在我开始之前.
我正在使用Datatables并且似乎无法使fnFilterAll API正常运行,即使他们的网站上给出了示例.我昨晚在几个小时的时间内完成了一次在线谷歌操作,令我沮丧的是,我找不到fnFilterAll的实际工作示例.
fnFilterAll API允许搜索多个表(对于那些想知道的人).
为了使事情变得简单,我创建了一个包含两个表的拆分页面.我想我错过了一些非常基本的东西,比如也许我必须指定列,但不知道在哪里这样做(在this.value区域?).无论如何,这是我的代码作为起点:
非常感谢任何帮助.感谢您的时间.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type">
<title>Testing Multi-Table Search Filter</title>
<style type="text/css" title="currentStyle">
@import"DataTables/media/css/demo_page.css";
@import"DataTables/media/css/demo_table.css";
#div1 {
background: #FFFDE0;
width: 49%;
height: 50%;
float: left;
}
#div2 {
background: #E2FFE0;
width: 49%;
height: 50%;
float: left;
}
#div-mid-spacer {
width: 2%;
height: auto;
float: left;
}
</style>
<script type="text/javascript" language="javascript" src="DataTables/media/js/jquery.js"></script>
<script type="text/javascript" language="javascript" src="DataTables/media/js/jquery.dataTables.js"></script>
<script type="text/javascript" charset="utf-8">
$.fn.dataTableExt.oApi.fnFilterAll = function(oSettings, sInput, iColumn, …Run Code Online (Sandbox Code Playgroud) jquery ×9
asp.net ×2
ajax ×1
anchor ×1
autocomplete ×1
backbone.js ×1
content-type ×1
css ×1
d3.js ×1
datatables ×1
download ×1
hover ×1
html ×1
html5 ×1
javascript ×1
jquery-ui ×1
mime-types ×1
replace ×1
servlets ×1
slider ×1
text ×1