我想在用户右键单击输入字段时禁用默认的contextMenu,以便我可以显示自定义的contextMenu.一般来说,通过执行以下操作非常容易禁用右键单击菜单:
$([whatever]).bind("click", function(e) { e.preventDefault(); });
Run Code Online (Sandbox Code Playgroud)
事实上,除了FF中的输入字段之外,我可以在几乎所有元素上执行此操作 - 任何人都知道为什么或可能指向某些文档?
以下是我正在使用的相关代码,谢谢大家.
HTML:
<script type="text/javascript">
var r = new RightClickTool();
</script>
<div id="main">
<input type="text" class="listen rightClick" value="0" />
</div>
Run Code Online (Sandbox Code Playgroud)
JS:
function RightClickTool(){
var _this = this;
var _items = ".rightClick";
$(document).ready(function() { _this.init(); });
this.init = function() {
_this.setListeners();
}
this.setListeners = function() {
$(_items).click(function(e) {
var webKit = !$.browser.msie && e.button == 0;
var ie = $.browser.msie && e.button == 1;
if(webKit||ie)
{
// Left mouse...do something()
} else if(e.button …Run Code Online (Sandbox Code Playgroud) 正如在最近的一篇文章中所指出的那样,范围内的模块不能按预期工作.
该线程的一个例子是:
Module[{expr},
expr = 2 z;
f[z_] = expr;
f[7]]
(*2 z*)
Run Code Online (Sandbox Code Playgroud)
但以下工作几乎与预期一致.
Module[{expr},
expr = 2 z;
Set@@{f[z_], expr};
f[7]]
(*14*)
Run Code Online (Sandbox Code Playgroud)
什么语言设计考虑使wolfram选择此功能?
编辑:请参阅Jefromi的第一条评论我将z从局部变量更改为not并忘记更改输出.它不会影响问题.
编辑2:Michael Pilat的观点似乎是Block和Module具有不同的功能.我想我理解他的观点,但我认为这与我的问题是正交的.所以这是一个更新.
我可以在笔记本中的全局级别使用以下代码:
expr = 2 z;
f[z_] = expr;
f[7]
(*output: 14*)
Run Code Online (Sandbox Code Playgroud)
但是当我将相同的代码块放入模块并使expr本地时,它会产生不同的输出.
Clear[f];
Module[{expr},
expr = 2 z;
f[z_] = expr;
f[7]]
(*output: 2z*)
Run Code Online (Sandbox Code Playgroud)
如果跟踪上面的模块调用,则会发现Set [f [z_],expr]被重写为Set [f [z $ _,expr].现在这个z-> z $转换发生在Set的lhs和rhs上.然而,它在expr被评估之前发生,这导致在全局级别获得不同的结果.
只有当rhs具有Module调用的本地符号时,才会发生转换z-> z $.
为什么Mathematica选择在模块调用中更改此语法?做出这个决定的是什么语言/实现设计权衡.
我试图使用opengl在xcode内部创建一个旋转的方块但是由于某种原因我有一个旋转的三角形?
我在sio2里面做这个,但我不认为这是问题所在.
这是三角形:http: //img220.imageshack.us/img220/7051/snapzproxscreensnapz001.png
这是我的代码:
void templateRender( void )
{
const GLfloat squareVertices[] ={
100.0f, -100.0f,
100.0f, -100.0f,
-100.0f, 100.0f,
100.0f, 100.0f,
};
const unsigned char squareColors[] = {
255, 255, 0, 255,
0, 255, 255, 255,
0, 0, 0, 0,
255, 0, 255, 255,
};
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
glClear( GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT );
// Your rendering code here...
sio2WindowEnter2D( sio2->_SIO2window, 0.0f, 1.0f );
{
glVertexPointer( 2, GL_FLOAT, 0, squareVertices );
glEnableClientState(GL_VERTEX_ARRAY);
//set up the color array …Run Code Online (Sandbox Code Playgroud) 我有一个函数来检查表单提交的年龄,然后根据年龄在div中返回新内容.现在我只是使用getElementById来替换html内容.我认为如果我也可以为div添加一个类,那对我来说会更好.所以例如我有..
if (under certain age) {
document.getElementById('hello').innerHTML = "<p>Good Bye</p>";
createCookie('age','not13',0)
return false;
} else {
document.getElementById('hello').innerHTML = "<p>Hello</p>";
return true;
}
Run Code Online (Sandbox Code Playgroud)
我想要做的是将所有东西都放在div中,如果返回false,那么div就会消失并被其他内容替换..我能用一个很好的方法获得任何想法,用纯粹的javascript实现这一点.我不想为这个特殊的功能使用jQuery.
我正在jQuery中创建一个内容旋转器.共5项.项目1淡入,暂停10秒,淡出,然后项目2淡入.重复.
很简单.使用setTimeout我可以调用一组创建循环的函数,并将无限期地重复该过程.
我现在想要通过单击导航元素来随时添加中断此旋转器的功能,以直接跳转到其中一个内容项.
我最初开始沿着不断地(例如每半秒)ping一个变量的路径,该路径将检查是否点击了导航元素,如果是,则放弃循环,然后根据单击的项重新启动循环.
我遇到的挑战是如何通过计时器实际ping一个变量.解决方案是深入研究JavaScript闭包......这有点超出我的想法,但绝对需要深入研究.
然而,在此过程中,我提出了一个替代选项,实际上似乎在性能上更好(理论上,至少).我在这里运行一个示例:
(它正在使用console.log,因此运行fireBug)
示例脚本:
$(document).ready(function(){
var loopCount = 0;
$('p#hello').click(function(){
loopCount++;
doThatThing(loopCount);
})
function doThatOtherThing(currentLoopCount) {
console.log('doThatOtherThing-'+currentLoopCount);
if(currentLoopCount==loopCount){
setTimeout(function(){doThatThing(currentLoopCount)},5000)
}
}
function doThatThing(currentLoopCount) {
console.log('doThatThing-'+currentLoopCount);
if(currentLoopCount==loopCount){
setTimeout(function(){doThatOtherThing(currentLoopCount)},5000);
}
}
})
Run Code Online (Sandbox Code Playgroud)
逻辑是每次点击触发元素都会启动循环,向自身传递一个等于全局变量当前值的变量.该变量在循环中的函数之间来回传递.
每次单击触发器也会增加全局变量,以便循环的后续调用具有唯一的局部变量.
然后,在循环内,在调用每个循环的下一步之前,它会检查它所具有的变量是否仍然与全局变量匹配.如果没有,它知道一个新的循环已经被激活,所以它只是结束现有的循环.
对此的想法?有效的方案?更好的选择?注意事项?危险?
更新:
我通过clearTimeout选项使用John的建议.
但是,我无法让它发挥作用.逻辑是这样的:
var slideNumber = 0;
var timeout = null;
function startLoop(slideNumber) {
//... code is here to do stuff here to set up the slide based on slideNumber...
slideFadeIn()
}
function continueCheck() {
if (timeout != null) {
// …Run Code Online (Sandbox Code Playgroud) 我目前正在尝试在代码中删除一些.Resolve.我一直在移动,直到我遇到一个命名注册,我无法使用该名称解析Autofac.我错过了将命名注册注入构造函数.
注册
builder.RegisterType<CentralDataSessionFactory>().Named<IDataSessionFactory>("central").SingleInstance();
builder.RegisterType<ClientDataSessionFactory>().Named<IDataSessionFactory>("client").SingleInstance();
builder.RegisterType<CentralUnitOfWork>().As<ICentralUnitOfWork>().InstancePerDependency();
builder.RegisterType<ClientUnitOfWork>().As<IClientUnitOfWork>().InstancePerDependency();
Run Code Online (Sandbox Code Playgroud)
现在的课程
public class CentralUnitOfWork : UnitOfWork, ICentralUnitOfWork
{
protected override ISession CreateSession()
{
return IoCHelper.Resolve<IDataSessionFactory>("central").CreateSession();
}
}
Run Code Online (Sandbox Code Playgroud)
想拥有
public class CentralUnitOfWork : UnitOfWork, ICentralUnitOfWork
{
private readonly IDataSessionFactory _factory;
public CentralUnitOfWork(IDataSessionFactory factory)
{
_factory = factory;
}
protected override ISession CreateSession()
{
return _factory.CreateSession();
}
}
Run Code Online (Sandbox Code Playgroud) 基于现有的表,我使用CTE递归查询来得出以下数据.但未能进一步应用它.
数据如下
id name parentid
--------------------------
1 project 0
2 structure 1
3 path_1 2
4 path_2 2
5 path_3 2
6 path_4 3
7 path_5 4
8 path_6 5
Run Code Online (Sandbox Code Playgroud)
我想以递归方式从上面的数据中形成完整路径.表示递归将提供以下输出.
FullPaths
-------------
Project
Project\Structure
Project\Structure\Path_1
Project\Structure\Path_2
Project\Structure\Path_3
Project\Structure\Path_1\path_4
Project\Structure\Path_2\path_5
Project\Structure\Path_3\path_6
Run Code Online (Sandbox Code Playgroud)
谢谢
我试图写一个简单的方法:
boolean validate(MyObject o)
{
// propertyA && propertyB are not primitive types.
return o.getPropertyA() == null && o.getPropertyB() == null;
}
Run Code Online (Sandbox Code Playgroud)
并且在这== null部分得到了一个奇怪的错误:
令牌==上的语法错误.赋值运算符无效.
也许我的Java在PLSQL的一个赛季后生锈了.所以我尝试了一个更简单的例子:
Integer i = 4;
i == null;
// compile error: Syntax error on token ==. Invalid assignment operator.
Integer i2 = 4;
if (i == null); //No problem
Run Code Online (Sandbox Code Playgroud)
怎么会这样?
我正在使用jdk160_05.
澄清:我不是要分配任何东西,只是&&在两个布尔值之间进行操作.我不想这样做:
if (o.propertyA() == null && o.propertyB() == null) { return true; }
else { return false; }
Run Code Online (Sandbox Code Playgroud) 我正在构建一个应用程序来搜索和识别用户在他/她的计算机中的任何iPhone应用程序.我想知道一种从.ipa文件中"提取"应用程序ID的方法.
我试图仅使用应用程序文件名进行识别,但我发现文件名不是Apple Store中应用程序的名称.Zynga现场扑克6K免费!=现场扑克3.7.ipa
我正在谈论的id是app id,如 http://itunes.apple.com/app/live-poker-6k-free-by-zynga/id354901953?mt=8,id 是354901953.
是否有任何机构有线索如何才能找到这些信息?
javascript ×2
autofac ×1
c# ×1
events ×1
input-field ×1
iphone ×1
itunes ×1
java ×1
jquery ×1
loops ×1
mysql ×1
opengl-es ×1
right-click ×1
sio2 ×1
sql ×1
sql-server ×1
t-sql ×1
xcode ×1