(set! *warn-on-reflection* true)
(proxy [javax.swing.JPanel] []
(paintComponent [#^java.awt.Graphics g]
(proxy-super paintComponent g)
(.fillRect g 100 100 10 10)))
Run Code Online (Sandbox Code Playgroud)
"反射警告,调用paintComponent无法解决"
我写了一个递归函数.出于某种原因,它在第一次运行后才会自行调用.它只需要循环中的下一个项目而不会更深入.我正在使用Visual Studio 10,而且我睡不着觉.
public IEnumerable<string> GeneratePath(int depth)
{
int presentDepth = depth;
char currentPosition = this.workingPath[presentDepth];
presentDepth++;
foreach (char nextPosition in this.moveTable.GetPossibleNextPositions(currentPosition))
{
this.workingPath[presentDepth] = nextPosition;
if (presentDepth < (ChessPiece.targetDepth - 1))
{
Console.WriteLine("At least this wasn't ignored:{0}", new string(this.workingPath));
this.GeneratePath(presentDepth);
}
else
yield return new string(this.workingPath);
}
}
Run Code Online (Sandbox Code Playgroud) 假设我们有以下HTML文件:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Test iframe download</title>
<script type="text/javascript">
var init = 0;
function download() {
document.getElementById("dload_frame").src = "http://example.com/dload.py";
}
function alert() {
if (init == 0) {
init = 1;
}
else {
document.getElementById("alert_span").innerHTML = "Got it!";
}
}
</script>
</head>
<body>
<span id="alert_span">Main content.</span><br/>
<input type="button" value="Download" id="btn" onclick="download()" />
<iframe id="dload_frame" src="http://404.com/404" onload="alert()"> </iframe>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
现在,如果iframe的src被重写到的URL(在这种情况下 - " http://example.com/dload.py ")返回HTML,没问题:onload事件触发,span的内容被替换,每个人的快乐.
但是,如果URL返回的文件的内容类型设置为强制浏览器打开保存文件对话框的内容,则iframe的onload事件永远不会触发.
有没有解决方法?不需要使用iframe,所需的行为是在浏览器开始下载提供的文件后启动回调.
我正在使用jquery和uploadify将照片上传到服务器.上传照片后,使用ajax将它们添加到div容器中.一切都很好,除了DELETE按钮.所有删除按钮都适用于页面加载,但通过ajax添加的按钮不起作用.我想这是因为我定义了能够删除图像的功能,并且没有使用"经典"删除方式(表单删除):
// Delete photo
$(".blog_slike .delete_slika").click(function() {
var commentContainer = $(this).parent().parent();
var id = $(this).attr("id");
var string = 'id='+ id ;
$.ajax({
type: "POST",
url: "./include/ajax-edit/delete.php?polje=blog_slika",
data: string,
cache: false,
success: function(){
commentContainer.fadeOut("slow");
$('#load').fadeOut();
}
});
return false;
});
Run Code Online (Sandbox Code Playgroud)
知道如何使用append()函数将按钮添加到html代码后使按钮工作吗?
还有一件事......将照片添加到tinymce编辑器中我使用此功能:
<a href=\"javascript:;\" onmousedown=\"tinyMCE.execCommand('mceInsertContent',false,'$slike_u_sadrzaj');\">Ubaci sve slike u blog</a>
Run Code Online (Sandbox Code Playgroud)
...也是在页面加载时添加的.如何将内容添加到所在$slike_u_sadrzaj位置以及如何删除它?
谢谢,Ile
我敢肯定,我不是唯一一个在Intellisense中扫描说事件并且不得不涉及所有属性等时发现它有点恼人的人.有没有方法/插件或东西只允许选择事件,只有属性等?
这真的是一大优点!
好,
我有一个新的MVC项目,它使用实体框架.我正在吐出消息(这是一个公告板样式部分),现在根据一些条件因素,表输出中的行必须具有不同的类样式.
从控制器传递到页面的模型是实体模型(称为消息并包含与数据库相同的字段)
现在为了得到行样式我做了以下,
<%
int i = 0;
foreach (var message in ViewData.Model.MessageList)
{
string className = "rowEven";
if (i % 2 == 0) { className = "rowOdd"; }
if (message.Deleted) { className = "deleted"; }
if (message.AuthorisedBy == null) { className = "notAuth"; }
if (message.Deleted) { className = "deleted"; }
%>
<tr class="<%=className%>">
<td><%= Html.CheckBox("mc1")%></td>
<td>
<%= Html.ActionLink(message.Title, "Details", new { id = message.MessageID })%>
</td>
<td>User Name Here</td>
<td><%= Html.Encode(message.PublishDateTime.ToString())%></td>
</tr>
<%
i++;
}
%>
Run Code Online (Sandbox Code Playgroud)
哪个非常难看,必须有更好的方法来做这个,有什么建议吗?
我想知道在网页中使用过多JavaScript代码会有什么缺点吗?
例如,我将为我的下拉菜单,选项卡和手风琴使用jQuery框架.和我的日历的其他JavaScripts(即使有可用的日历,使用jQuery)和其他JavaScript的其他东西?有什么影响?(我认为JavaScript与重载相矛盾)
我知道很多开发人员掌握了2个以上的JavaScript框架.我的问题是:在开发项目时,如何为该项目选择JavaScript框架?为什么要为该项目使用MooTools或jQuery?(我知道这是一个选择问题),但还有其他原因吗?就像mootools对此有好处......或者jQuery对此有好处......
我想听听你的意见.
我正在为Windows窗体应用程序创建单元测试.我的一个方法是表单的事件处理程序(我不知道这是否是我的问题的来源):
private void ImportButton_Click(object sender, System.EventArgs e)
{
// blah blah
}
Run Code Online (Sandbox Code Playgroud)
现在,当我尝试通过右键单击源 - >"创建单元测试"来创建此方法的单元测试时,一切似乎都正常工作,直到我打开生成的单元测试代码:
/// <summary>
///A test for ImportButton_Click
///</summary>
[TestMethod()]
[DeploymentItem("FooBar.exe")]
public void ImportButton_ClickTest()
{
// Creation of the private accessor for 'Microsoft.VisualStudio.TestTools.TypesAndSymbols.Assembly' failed
Assert.Inconclusive("Creation of the private accessor for \'Microsoft.VisualStudio.TestTools.TypesAndSy" +
"mbols.Assembly\' failed");
}
Run Code Online (Sandbox Code Playgroud)
任何想法如何解决这一问题?我发现这个MSDN论坛帖子详细说明了一个我认为不适用于我的问题的类似问题.
是否可以指定参数:连接类似于:条件的方式?
这是一个例子(sql代码无关紧要)
named_scope :threads, {
:joins => [" LEFT JOIN groups_messages gm ON messages.id=gm.message_id AND gm.group_id IN (?) ",@group_ids_array],
:conditions => ["creator_id=? AND messages.id IN (?)", current_user_id, @message_ids_array]
}
Run Code Online (Sandbox Code Playgroud)
在这个示例参数:条件将正确插入,但对于:连接我会得到一个错误
Association named ' LEFT JOIN groups_messages gm ON messages.id=gm.message_id and gm.group_id IN (?) ' was not found; perhaps you misspelled it?
Run Code Online (Sandbox Code Playgroud)
什么函数替换参数:条件?
c# ×2
javascript ×2
jquery ×2
ajax ×1
algorithm ×1
append ×1
asp.net-mvc ×1
clojure ×1
command-line ×1
download ×1
iframe ×1
intellisense ×1
java ×1
join ×1
mootools ×1
onload ×1
picocli ×1
prototypejs ×1
recursion ×1
reflection ×1
substitution ×1
tag-soup ×1
unit-testing ×1
winforms ×1