小编Rob*_*Rob的帖子

JQuery将click事件绑定到复选框

这是我的html的基本视图:

<form>
  <div id="part1">
     // some html form elements including checkboxes
  </div>
  <div id="part2">
    // more html code with more checkboxes
  </div>
  <div id=part2">
     // data table with numerous checkboxes built dynamically
  </div
</form>
Run Code Online (Sandbox Code Playgroud)

我需要做的是将.click()事件分别绑定到第1部分,第2部分和第3部分中的复选框.我试过这个$('#part1:checkbox').click(...)但是没用.如果我使用$("form :checkbox").click(...)相同的点击事件绑定到所有复选框而不仅仅是一组.我怎么分开这些?

jquery bind

9
推荐指数
1
解决办法
4万
查看次数

在包含保留字时设置CSS代码

我想做的事情:正如标题中所述,我想设置一个单词的CSS,如果它是一个保留字.


HTML

<html>
    <body>
        <code id="java">
            public static void main(String[] args)<br>
            {
                <pre>    System.out.println("Hello World!");</pre>
            }
        </code>
    </body>
</html>
Run Code Online (Sandbox Code Playgroud)


jQuery的

$(document).ready(function()
{
    // Get the text inside the code tags
    var code  = $("#java").text();

    // Split up each word
    var split = code.split(' ');

    // Array of reserved words
    var array = ["abstract","assert","boolean","break","byte","case",
                 "catch","char","class","const","continue","default",
                 "do","double","else","else if","enum","extends","final",
                 "finally","float","for","goto","if","import","implements",
                 "instanceof","int","interface","long","native","new","null",
                 "package","private","protected","public","return","short",
                 "static","strictfp","super","switch","synchronized","this",
                 "throw","throws","transient","void","volatile","while"];

    // Added when text contains a reserved word
    var css = {'font-weight':'bold','color':'#2400D9'}

    array = jQuery.map(array, function(n,i)
    {
        for …
Run Code Online (Sandbox Code Playgroud)

html javascript css jquery reserved-words

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

写入/ sys/class/gpio/export失败

我正在开发一个项目,需要我配置gpio引脚并在原子板上添加传感器.内核配置了gpio ... CONFIG_GPIO_SYSFS=y是内核选项之一.

我正在使用Fedora版本2.6.29-10
但是我无法写入gpio文件夹中的导出文件

GPIO=22  // to add pin 22 to userspace  
echo $GPIO > /sys/class/gpio/export
Run Code Online (Sandbox Code Playgroud)

我收到了错误
bash: echo: write error: Invalid argument

我也试过同样与sudosh -c,但没有用,除非我可以公开这些引脚用户空间,我不能写任何code.What我做错了什么?
是否需要设置内核版本或其他一些内核选项的问题?

提前致谢

gpio

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

AlertDialog.Builder打开另一个AlertDialog.Builder

我试图打开AlertDialog另一个AlertDialog,但它不起作用,任何想法为什么它不起作用?

String items[] = {"Details","Edit","Delete"}
AlertDialog.Builder alert = new AlertDialog.Builder(getAplicationContext());
alert.setTitle("Options");
alert.setItems(items, new OnClickListener() {

    public void onClick(DialogInterface dialog, int item) {
        switch(item){
            case 0:
                AlertDialog.Builder alert2 = new AlertDialog.Builder(getAplicationContext());
                alert2.setTitle("Details");
                alert2.setMessage(getDetails());
                alert2.setNeutralButton("Close", null);
                alert2.show();
            return;

            case 1:
                //not important for the question
            return;

            case 2:
                //not important for the question
            return;
        }
    }
});

alert.setNegativeButton("Cancel", null);
alert.show();
Run Code Online (Sandbox Code Playgroud)

android dialog android-alertdialog

3
推荐指数
1
解决办法
2043
查看次数

转换为JSON,如何包含多级深度模型?

a has_many Bs
B has_many Cs
B belongs_to A
C belongs_to B
C belongs_to A.

但是当我这样做时myA.to_json(:include => [:b, :c]),一切都处于最高级别,这是有道理的,但是如何将params传递给to_json,使得Cs将位于B下的数组中,而不是A?

我认为它看起来应该是这样的:myA.to_json(:include => [:b => :c])
我将这个看作myA,json,同时包括b,其中包括c.

ruby

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

在Objective-C中分配属性

我有关于在Objective-C中分配属性的以下问题,

如果我有以下财产:

@property (nonatomic, retain) NSArray *arr;
@synthize arr=_arr;
Run Code Online (Sandbox Code Playgroud)

我应该像这样分配这个数组:

arr=[[NSArray alloc]init];
Run Code Online (Sandbox Code Playgroud)

如果我愿意,分配它的最佳位置在哪里?

我知道我应该释放它,但是保留一个属性会使其保留计数增加1并且分配它会使它增加1,我是对的.

iphone xcode cocoa-touch memory-management objective-c

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

TableView popover不被解雇[self dismissPopoverAnimated:YES];

我有一个popover,显示一个包含几个单元格的tableview.触摸单元格时,它会调用以下代码:

(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSLog(@"Cell check %@", [totalArray objectAtIndex:indexPath.row]);
    [self dismissPopoverAnimated:YES];
}
Run Code Online (Sandbox Code Playgroud)

我知道这个方法被调用,因为NSLOG显示它应该的文本.问题是弹出窗口没有被解雇.我以为

[self dismissPopoverAnimated:YES];
Run Code Online (Sandbox Code Playgroud)

应该解雇popover?我究竟做错了什么?

iphone objective-c ipad ios

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