有没有办法可以使用ajax动态加载内容并保留加载内容可能具有的任何jquery功能?
例如,我想在Twitter中加载DB记录的提要.每条记录都可以竖起大拇指或竖起大拇指.投票使用了一些AJAX,并且在加载到父页面时我无法保留事件功能.
好的原谅这样一个noob问题,但我迷失在jquery页面上的例子.当它说:
$('a').click(fn);
$('#mydiv').load('my.html',function(){
$('a').click(fn); });
Run Code Online (Sandbox Code Playgroud)
fn应该代表什么?
我来自C++和JAVA,其中Scope有全局或本地.
我现在正在学习ruby-on-rails和ruby,有本地,实例和全局.直到现在我才真正听说过这个例子.
有或没有rails,实例变量的理解和用法是什么?
Global = Variable across all objects share
Instance = Variable inside of the object
Local = Variable inside of the object
Run Code Online (Sandbox Code Playgroud)
我想我的实例和当地有点混合在一起.
@ham
ham
Run Code Online (Sandbox Code Playgroud)
这两个不同的变量对吧?有时我在Rails中感到困惑,因为他们使用的东西可以像@something和:某些东西.这是为什么?
因为我使用rails框架,所以我理解实例变量是视图可以访问的东西.
有人可以澄清这些变量吗?
我可以将当前渲染位置设置为任意值,而不是仅仅从当前位置给它一个偏移量吗?
这就是我目前正在做的事情:
gl.glTranslatef(3.0f, 0.0f, 2.0f);
Run Code Online (Sandbox Code Playgroud)
它允许我说"我想向左移动"而不是"我想移动到点(2,1,2)".有办法做后者吗?
我正在使用OpenGL和JOGL.
更新:
@Bahbar建议如下:
gl.glLoadIdentity();
gl.glTranslatef(...);
Run Code Online (Sandbox Code Playgroud)
当我这样做时,除了六行之外的所有东西都会消失.我不知道为什么.我有一个问题,远剪裁平面太近,所以也许它们太远而无法渲染.
我知道其他人已经问过这个问题了,但我对此完全感到困惑:
这将显示未选择任何值的下拉列表:
<%= Html.DropDownList("items", new MultiSelectList(Model.AvailableItems,
"id", "name", Model.items), new { multiple = "multiple" })%>
Run Code Online (Sandbox Code Playgroud)
这将显示下拉列表,其中包含我正在传入的值(Model.items),就像我期望的那样:
<%= Html.DropDownList("somethingelse", new MultiSelectList(Model.AvailableItems,
"id", "name", Model.items), new { multiple = "multiple" })%>
Run Code Online (Sandbox Code Playgroud)
但问题是,当我发布POST时,此项目现在被命名为"somethingelse".我知道我可以解决这个问题但是会发生什么?
我正在尝试运行此处给出的示例切片示例.
下面是我的POM.xml:
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-api</artifactId>
<version>2.1.2</version>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-core</artifactId>
<version>2.1.2</version>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-jsp</artifactId>
<version>2.1.2</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.5.2</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
当我试图运行该示例时,抛出以下错误:
Sep 17, 2010 11:59:43 PM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Error configuring application listener of class org.apache.tiles.web.startup.TilesListener
java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder
at org.slf4j.LoggerFactory.<clinit>(LoggerFactory.java:60)
at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:155)
at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:131)
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:685)
at org.apache.tiles.web.startup.TilesListener.<init>(TilesListener.java:49)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
Run Code Online (Sandbox Code Playgroud)
任何的想法?
我花了30分钟谷歌搜索,但找不到可能的溶剂.
请帮我...
更新:我感谢所有的评论,这些评论基本上都是一致的反对意见.虽然提出的每一项反对意见都是有效的,但我觉得棺材中的最终指甲是Ani的精明观察,最终,即使是这个想法表面上提供的一个 微不足道的好处 - 消除样板代码 - 也被这个事实所否定.想法本身需要自己的样板代码.
所以,是的,请相信我说:这将是一个坏主意.
而且只是为了有点挽救我的尊严:我可能是出于争吵的缘故而玩弄它,但我从来没有真正把这个想法卖掉 - 只是好奇地听到别人不得不说的话.诚实.
在你将这个问题视为荒谬之前,我请你考虑以下问题:
IEnumerable<T>从继承*IEnumerable,这意味着实现任何类型的IEnumerable<T>通常必须实现两个 IEnumerable<T>.GetEnumerator 和(明确地)IEnumerable.GetEnumerator.这基本上等于样板代码.foreach覆盖任何具有GetEnumerator方法的类型.因此,如果您的类型使用签名定义了一个方法,那么使用它来枚举它是合法的.MoveNextCurrentpublic IEnumerator<T> GetEnumerator()foreachIEnumerable<T>接口 - 例如,基本上所有的LINQ扩展方法.幸运的是,使用C#通过关键字提供的自动迭代器生成,从可以使用的类型foreach转变IEnumerable<T>为简单的类型yield.所以,把这一切放在一起,我有这个疯狂的想法:如果我只是定义我自己的界面,如下所示:
public interface IForEachable<T>
{
IEnumerator<T> GetEnumerator();
}
Run Code Online (Sandbox Code Playgroud)
然后每当我定义一个我想要枚举的类型时,我实现这个接口而不是IEnumerable<T>,不需要实现两个GetEnumerator方法(一个显式).例如:
class NaturalNumbers : IForEachable<int>
{
public IEnumerator<int> GetEnumerator()
{
int …Run Code Online (Sandbox Code Playgroud) 我将<a>元素设置如下
a:link {color:#FF0000;} /* unvisited link */
a:visited {color:#00FF00;} /* visited link */
a:hover {color:#FF00FF;} /* mouse over link */
a:active {color:#0000FF;} /* selected link */
Run Code Online (Sandbox Code Playgroud)
在下面使用Firefox,Opera和Chrome
<a href="mailto:userid@xyz.edu" >send email</a>
Run Code Online (Sandbox Code Playgroud)
所有颜色都按预期运行,但它永远不会被标记为已访问.有没有办法让它访问?
这是IE似乎擅长的一个地方,因为它确实标记为访问!
我得到的错误是:名称agentName在当前上下文中不存在"
在default.aspx我有 <asp:TextBox ID="agentName" runat="server" />
我有文件背后的代码 agentName.Text
但是说上面的错误信息.
当我传递像"约翰"这样的硬编码值时,它有效.我需要一种方法来识别代码隐藏的文本框.
谢谢
以下是我的代码:
Default.aspx的:
//code behind on @page directive
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="WebApplication2.WebForm1"%>
// Getting the value from XML
Agentname.Text = root.SelectSingleNode("name").ChildNodes[0].Value;
// Assigned a textbox
asp:TextBox ID="Agentname" runat="server" disabled="true" MaxLength="57" /
(removed angel bracket as SO is ignoring this line, don't know why)
//Code behind
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using …Run Code Online (Sandbox Code Playgroud) 我有一个wpf应用程序,我创建了一个登录窗口,用于构建应用程序的连接字符串.我在关闭第一个对话框并旋转打开后面的MainWindow时遇到问题.我认为一个关闭事件正在冒出登录对话框并陷入MainWindow,因为只要我在代码隐藏中创建MainWindow对象并调用Show()它就会直接移动到我的Startup事件处理程序并进入我的构造函数然后onWosing MainWindow的处理程序,而不显示窗口本身.app.xaml指定了ShutdownMode ="OnMainWindowClose".
private void Application_Startup(object sender, StartupEventArgs e)
{
try
{
Chooser thechooser = new Chooser();
thechooser.ShowDialog();
}
catch (Exception ex)
{
}
//initialize datalayer
dataLayer = new Mxxx41.DAL(this.CurrentConnectionString);
MainWindow appmainwindow = new MainWindow();
Application.Current.MainWindow = appmainwindow;
appmainwindow.Activate();
appmainwindow.Show();
}
private void LogInButton_Click(object sender, RoutedEventArgs e)
{
//get ip from listbox selection
XmlElement currentelement = (XmlElement)Listbox.SelectedItem;
string ip = ((string)currentelement.Attributes["IP"].Value);
string instancename = string.Empty;
if (!((string)currentelement.Attributes["InstanceName"].Value == string.Empty))
{
instancename = ((string)currentelement.Attributes["InstanceName"].Value);
}
//ping that IP
Boolean pingresult = …Run Code Online (Sandbox Code Playgroud) 我是C的新手.我最近在C中遇到了这段代码:
#include <stdio.h>
int main()
{
unsigned Abc = 1;
signed Xyz = -1;
if(Abc<Xyz)
printf("Less");
else
if(Abc>Xyz)
printf("Great");
else
if(Abc==Xyz)
printf("Equal");
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我尝试运行它并输出"Less".它是如何工作的?unsigned Abc是什么意思?我可以理解unsigned char Abc,但只是未签名的Abc?我很确定Abc不是数据类型!如何(和为什么?)这样做?