小编Phi*_*lip的帖子

Jquery - 从元素中删除类后仍然有效

我不知道它是否应该像这样,我做的事情根本就是错误的.

我有一个div给定的类,当你点击div它给出一个响应,但后来我有另一个div,当点击那个它从第一个删除该类div.

但是当我div在删除课程后继续点击第一个时,我会继续得到回复.

在我删除课程后,为什么点击会继续响应?

HTML

<div class="testing">Testing</div>

<div id="testing_remover">Remove class from testing</div>
Run Code Online (Sandbox Code Playgroud)

JS:

$(document).ready(function(){
    $('.testing').click(function(){
        console.log('testing is active');
    });

    $('#testing_remover').click(function(){
        $('.testing').removeClass('testing');
    });
});
Run Code Online (Sandbox Code Playgroud)

小提琴:http://jsfiddle.net/P3NpK/

javascript jquery class function

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

Ruby - 查找字符串中最长的3个单词

我希望能够从字符串中获取3个最长的单词.有没有一个简洁的方法来做这个而不进入数组等?

ruby arrays string

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

Rails - 在flash通知中传递变量

我一直在尝试在创建帖子时出现的flash通知中添加一个变量 #{variable}

但我必须遗漏一些东西,因为我收到的唯一信息是"#{variable}".

这是我的控制器:

 def create

    @participant = Participant.new(params[:participant])

    respond_to do |format|
      if @participant.save
        mail = params[:email]
        format.html { redirect_to @participant, notice: 'Thanks, We will be sending out instructions to:  #{mail}' }
        format.json { render json: @participant, status: :created, location: @participant }
      else
        format.html { render action: "new" }
        format.json { render json: @participant.errors, status: :unprocessable_entity }
      end
    end
  end
Run Code Online (Sandbox Code Playgroud)

我一直在尝试使用@participants作为变量,但是,除了消息中的实际"#{@ participant}"之外,我什么都得不到.

ruby variables ruby-on-rails

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

Imagemagick Mogrify裁剪输出名称

使用时 mogrify -crop 500x500 *.jpg

我输出为 *-1.jpg, *-2.jpg, *-3.jpg, *-4.jpg

是否可以更改以使其获得不同的分隔符.例如.强调?

输出: *_1.jpg, *_2.jpg, *_3.jpg, *_4.jpg,

filenames crop imagemagick mogrify

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

Ruby Guard Watch表现得非常慢

我使用最新版本的Guard和Guard-Haml.我在根目录中有7张地图,我将Haml文件存储在两个不同的目录中.一个在/ templates/haml中,一个在/ haml中.haml文件的总和小于10.

在其他5张地图中,我有大约17 000个文件.我已将guard配置为仅在/ haml和/ templates/haml映射中进行更改.我开始使用它之后工作正常bundle exec guard,但过了一段时间它变得很慢.从我更改文件大约30秒后,它需要重新编译文件.

这是我的Guardfile

require 'haml/helpers'
require 'haml/filters'
require 'haml/filters/php'

guard :haml, input: 'www/templates/haml', output: 'www/templates', :haml_options => { :escape_attrs => false } do
  watch %r{^www/templates/haml/.+(\.haml)$}
end

guard :haml, input: 'www/haml', output: 'www/', :haml_options => { :escape_attrs => false } do
  watch %r{^www/haml/.+(\.haml)$}
end
Run Code Online (Sandbox Code Playgroud)

有什么办法可以加快速度,因为它真的会减慢我的开发速度.下.

ruby performance haml guard

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