小编and*_*lrc的帖子

如何仅处理子元素的委托事件?

使用.on如何定位子元素时委派事件:

我试过了: childSelector =

  • >*
  • >:nth-child(n)

但是当我开始时没有选择任何东西>.

$(selector).on(event, childSelector, handler);
Run Code Online (Sandbox Code Playgroud)

有时我想针对一个直接的孩子,有时我不会:(伪代码)

var func = function(selector, subSelector) {
    $(selector).on("click", subSelector, function() {
        alert("my subSelector is clicked");
    });
}

func("#wrapper", "direct-child-selector");
func("#wrapper", ".some .other > .selector:first");
Run Code Online (Sandbox Code Playgroud)

这就是为什么我要求选择器而不是修复.

javascript jquery events delegates children

8
推荐指数
1
解决办法
4099
查看次数

MediaScanner ServiceConnectionLeaked

我使用这个类在SDCard中扫描我的应用程序图像.

public class SingleMediaScanner implements MediaScannerConnectionClient {

private MediaScannerConnection mMs;
private File mFile;

public SingleMediaScanner(Context context, File f) {
    mFile = f;
    mMs = new MediaScannerConnection(context, this);
    mMs.connect();
}

@Override
public void onMediaScannerConnected() {
    mMs.scanFile(mFile.getAbsolutePath(), null);
}

@Override
public void onScanCompleted(String path, Uri uri) {
    mMs.disconnect();
}
}
Run Code Online (Sandbox Code Playgroud)

它工作但在我的LogCat中它总是显示错误:

12-29 16:44:16.022: ERROR/ActivityThread(21807): Activity com.cny.ecard.CustomListDialog has leaked ServiceConnection android.media.MediaScannerConnection@450fb8e0 that was originally bound here
12-29 16:44:16.022: ERROR/ActivityThread(21807): android.app.ServiceConnectionLeaked: Activity com.cny.ecard.CustomListDialog has leaked ServiceConnection android.media.MediaScannerConnection@450fb8e0 that was originally bound here
12-29 16:44:16.022: …
Run Code Online (Sandbox Code Playgroud)

android android-mediascanner

7
推荐指数
1
解决办法
7028
查看次数

错误:"/run/nginx.pid"中的PID编号""无效

我的nginx没有启动80端口.

我添加了以下详细信息:

$ nginx -s reload
2016/03/23 16:11:27 [error] 24992#0: invalid PID number "" in "/run/nginx.pid"
$ ps -ef | grep nginx
root     25057  2840  0 16:16 pts/1    00:00:00 grep --color=auto nginx
$ kill -9 25057
bash: kill: (25057) - No such process
$ service nginx start
Nothing..
Run Code Online (Sandbox Code Playgroud)

请提供解决方案..

linux bash nginx

7
推荐指数
2
解决办法
1万
查看次数

html5/android touchcancel

我尝试在html5移动版上使用界面.我尝试用touchstart/touchmove/touchend/touchcancel来实现这一目标.但是,当我试图遵循一个mouvement时,我总是快速地拥有au'touchcancel',然后再没有触摸......

当我尝试这个:http://miniapps.co.uk/code/touchcancel/ 它完美的工作,我没有任何问题.

但我认为这个问题来自于干扰我画布的Web浏览器.你知道我可以解决这个问题吗?

//我试着解释一下: - 这是我的测试代码:http://frys.free.fr/mNaissance/test.html 这是我试图使用移动设备的"Jigsaw"拼图代码.我在文本中有一个"日志"div.当我在灰色画布上"触摸移动"时,我有一个非常快的'touchcancel'而且没有'touchmove'它更清楚了吗?抱歉我的英语不好!

感谢帮助

html5 android

6
推荐指数
1
解决办法
2676
查看次数

JavaScript Node.js日期比较和数组按日期排序

首先,JavaScript没有像Python那样的基本日期比较吗?

在我的Node.js脚本中,我有以下几行:

console.log(Date(2012,11,10) < Date(2012, 11, 9))
console.log(Date(2012,11,10) > Date(2012, 11, 9))
Run Code Online (Sandbox Code Playgroud)

但是,这两行都返回false.

似乎有很多关于"JavaScript中的日期比较"的问题.

然而,对于几乎所有人来说,有人用他们的自制解决方案来回应比较日期,其中一些很长和/或"hacky".

是否真的没有固有或惯用的方式来简单比较JavaScript中的日期.
任何Node库都支持它吗?

javascript date node.js

6
推荐指数
1
解决办法
2万
查看次数

带有CF轮和ColdFusion的Tuckey URL重写过滤器11

我接管了一个在ColdFusion 10中使用CF Wheels构建的应用程序,它被设计为在Linux上运行.它使用Tuckey URL Rewrite过滤器来清理URL.我正在尝试在Windows机器上设置它并使用ColdFusion 11,但我遇到了Tuckey URL Rewrite过滤器的问题.

问题是它切断mcfm文件扩展名,因此ColdFusion会抛出File Not Found错误,因为当然没有"rewrite.cf"文件.我还注意到在调试输出中CGI.PATH_TRANSLATED变量以CG结尾rewrite.cf,而CGI.PATH_INFO以"m/[无论目录路径]"结尾,所以过滤器正在切断它应该重写的文件名.当我使用重写URL的"to"部分中的"反向引用"来传递目录路径时,似乎只会发生这种情况rewrite.cfm.如果我只是重定向到一个普通的cfm,而不进行反向引用,它工作正常.其他测试重写规则也可以正常工作,重写状态在我的localhost上看起来很好.有人有主意吗?

下面是我的规则urlrewrite.xml以及搞乱的PATH_TRANSLATED和PATH_INFO变量的截图.除了转移到Windows和CF 11之外,另一个区别是我在wwwroot("portal")的子目录中运行应用程序,但我已经在wwwroot级别应用了过滤器和规则,并在重写规则中指定了目录.

<rule>
    <note>Apply CFWheels URL rewriting for portal.</note>
    <condition type="request-uri" operator="notequal">^/portal/$</condition>
    <condition type="request-uri" operator="notequal">^/portal/favicon.ico$</condition>
    <condition type="request-uri" operator="notequal">^/portal/cfide(.*)$</condition>
    <condition type="request-uri" operator="notequal">^/portal/images(.*)$</condition>
    <condition type="request-uri" operator="notequal">^/portal/javascripts(.*)$</condition>
    <condition type="request-uri" operator="notequal">^/portal/stylesheets(.*)$</condition>
    <condition type="request-uri" operator="notequal">^/portal/rewrite.cfm(.*)$</condition>
    <from>^/portal/(.*)$</from>
    <to type="passthrough" last="true">/portal/rewrite.cfm/$1</to>
</rule>
Run Code Online (Sandbox Code Playgroud)

Tuckey重写问题

coldfusion cfwheels tuckey-urlrewrite-filter

6
推荐指数
0
解决办法
182
查看次数

背景图像灰度

我在我的网站上使用颜色作为背景,在顶部我有一个图像。我想用 css 把这张图片变成黑白的:

body {
    background: url('background.jpg') center top no-repeat;
    -webkit-filter: grayscale(100%);
}
Run Code Online (Sandbox Code Playgroud)

但是这段代码使整个网站灰度化

我还尝试将网站内容放入带有样式的新 div 中,-webkit-filter: none;但它也不起作用。

html css

6
推荐指数
1
解决办法
2832
查看次数

管git diff到git应用

为什么这个命令不起作用?

git diff | git --git-dir=/other/location/.git --work-tree=/other/location apply
Run Code Online (Sandbox Code Playgroud)

以下工作完美:

git diff > /tmp/my.patch
cd /other/location && git apply /tmp/my.patch
Run Code Online (Sandbox Code Playgroud)

/other/location 是当前目录的镜像.

通过管道命令,我得到了

error: patch failed: myfile.php:1
error: myfile.php: patch does not apply
Run Code Online (Sandbox Code Playgroud)

git shell patch zsh

6
推荐指数
1
解决办法
3435
查看次数

如何深度克隆iframe?

有没有办法深度克隆iframe?

基本的jQuery克隆只是使用相同的src创建另一个iframe.我想实现的是克隆的iframe的方式,它的准确的当前内容(即任何可能的输入值,通过JavaScript等任何DOM修改).

var clone = iframe.contents().find('html').clone();
Run Code Online (Sandbox Code Playgroud)

当我克隆HTML属性及其所有子项,修改等时,我遇到了以下问题:

  1. 我错过了DOCTYPE

  2. 如何将其插入新的iFrame?

javascript iframe

5
推荐指数
1
解决办法
6443
查看次数

检查字符串是否为零,零,空字符串,为空

在PHP中:

$var=0;
$var="";
$var="0";
$var=NULL;
Run Code Online (Sandbox Code Playgroud)

验证$ var是0还是"0"或""或NULL

if (!$var) {...}
Run Code Online (Sandbox Code Playgroud)

在jQuery/JavaScript中:

$var=0;
$var="";
$var="0";
$var=NULL;
Run Code Online (Sandbox Code Playgroud)

if (!$var) 适用于除"0"以外的所有值

在JavaScript/jQuery中是否有一种通用方法来检查所有类型的空/ null /零值,就像php一样?

javascript jquery

5
推荐指数
2
解决办法
5045
查看次数