标签: bind

boost :: bind访问器?

假设我有以下代码:

int f(int, int);

int main()
{
    SomeFunc(boost::bind(f, 1, 2));
}
Run Code Online (Sandbox Code Playgroud)

从SomeFunc()函数,是否可以访问绑定类型持有的参数?像这样的东西(伪代码):

// Obvious syntax issues...
void SomeFunc(boost::bind& functor)
{
    if(functor.function == &f)
    {
        if(functor.argument1 == 1)
            DoSomething();
    }
}
Run Code Online (Sandbox Code Playgroud)

我可以从boost :: bind类型中提取这些信息吗?

c++ boost bind boost-bind

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

Jquery绑定事件

我有以下代码:

$('#form_field, #button').bind('change click', function() {
// take action
});
Run Code Online (Sandbox Code Playgroud)

它工作正常.但是,我想在'#form_field'使用'change'时触发相同的操作,'#button'使用'click'(而不是'click_field'使用'click').

我知道可以使用以下代码完成:

$('#form_field').bind('change', function() {
// take action
});

$('#button').bind('click', function() {
// take action
});
Run Code Online (Sandbox Code Playgroud)

但是,我不想重复函数内部的所有代码(//采取行动).它看起来效果不佳,每次我对它进行更改时我都需要编辑两次.

有任何想法吗?

提前致谢

jquery events bind

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

jQuery:将相同的事件绑定到窗口和另一个元素

如何将同一事件window一次性绑定到另一个元素以及另一个元素.我尝试过这个,但它对我不起作用:

$('window, #someId').bind('click', doSomething);
Run Code Online (Sandbox Code Playgroud)

javascript jquery bind

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

Android后台服务

我正在阅读文档,花费的时间越多,我就会越来越困惑,这是实现我想做的最简单的方法.我想写一个简单的服务,它从按钮onClick开始并绑定到活动.当活动关闭并稍后再次启动时(不仅重新启动!),我想检查服务是否已经运行并绑定到它.我该怎么做?

谢谢

service android background bind android-activity

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

如何在我的函数中使用.bind()

我有一个功能,在网页上推进滚动图像.可以在这里看到:

http://leadgenixhosting.com/~intmed/

右箭头是您单击以前进图像的内容.我有这个问题,我使用.unbind(),以便箭头不可点击,直到图像完成.animate(),以便它们不会失去同步.但我不确定如何使用.bind()使箭头再次点击.

这就是函数目前的样子:

$('#in-right').click(
        function(){
            $('#in-right').unbind('click');
            imageSwitch();
            $('#in-right').bind('click');
        }
);
Run Code Online (Sandbox Code Playgroud)

我显然错误地实现了绑定.我该如何实施呢?

这是我的imageSwitch()函数:

function imageSwitch(){

        current++;
        current_image++;
        previous_image++;
        next++;
        two_prev++

        if(two_prev >= divs.length){
            two_prev = 0;   
        }

        if(current >= gallery_images.length){
            current = 0;    
        }

        if(previous_image >= divs.length){
            previous_image = 0; 
        }

        if(current_image >= divs.length){
            current_image = 0;
        }

        if(next >= divs.length){
            next = 0;
        }   

        $('#'+divs[current_image]+'').animate({left:'-=1020px'},{queue:false,duration:1000})
        $('#'+divs[current_image]+'').css('background-image','url('+gallery_images[current]+')');

        $('#'+divs[previous_image]+'').animate({left:'-=1020px'},{queue:false,duration:1000});

        $('#'+divs[next]+'').animate({left: '+=1020px', top: '-=10000px'}, 1000);

        $('#'+divs[two_prev]+'').animate({left: '+=1020px', top: '+=10000px'}, 1000);
    }
Run Code Online (Sandbox Code Playgroud)

javascript jquery bind

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

在C++中使用算法头文件时出错

我创建了一个unix域服务器客户端.它完美无缺地运行.

然后我想使用头文件中的random_shuffle()函数algorithm.所以我只包含algorithm头文件.我没有做任何其他改动.但是现在在编译时我收到以下错误:

game.cpp:102:85: error: no match for ‘operator!=’ in ‘std::bind(_Functor&&, _ArgTypes&& ...) [with _Functor = int&, _ArgTypes = {sockaddr*, long unsigned int}, typename std::_Bind_helper<_Functor, _ArgTypes>::type = std::_Bind<int(sockaddr*, long unsigned int)>]((* &((sockaddr*)(& address))), (* &110ul)) != 0’
game.cpp:102:85: note: candidates are:
/usr/include/c++/4.6/bits/stl_pair.h:214:5: note: template<class _T1, class _T2> constexpr bool std::operator!=(const std::pair<_T1, _T2>&, const std::pair<_T1, _T2>&)
/usr/include/c++/4.6/bits/stl_iterator.h:297:5: note: template<class _Iterator> bool std::operator!=(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_Iterator>&)
/usr/include/c++/4.6/bits/stl_iterator.h:347:5: note: template<class _IteratorL, class _IteratorR> bool std::operator!=(const std::reverse_iterator<_IteratorL>&, const std::reverse_iterator<_IteratorR>&) …
Run Code Online (Sandbox Code Playgroud)

c++ bind include

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

BIND通配符子域上的DNS查找问题

那里有很多教程,但是我很难获得BIND来提供本地网络DNS查找.

目的:

  • 可以从本地网络上的任何位置进行请求.(我没有包括任何listen on陈述,所以应该涵盖 - 我想!)
  • *.demo 请求应该去 192.168.0.64
  • 其他任何东西都应转发给谷歌8.8.8.88.8.4.4

这是我的配置:

# /etc/named.conf
options {
  directory "/var/named";
  # Hide version string for security
  version "not currently available";

  # Forward all unknown DNS queries to the Google Public DNS. (Does it?)
  forwarders { 8.8.8.8; 8.8.4.4; };

  dnssec-validation auto;

  auth-nxdomain no;    # conform to RFC1035
  listen-on-v6 { any; };
};

zone "demo." IN {
  type master;
  file "zone.demo";
};
Run Code Online (Sandbox Code Playgroud)

和区域文件:

; /var/named/zone.demo
$ORIGIN demo.
$TTL 1D
@ …
Run Code Online (Sandbox Code Playgroud)

dns bind

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

JavaScript一次性在几个元素上注册一个事件类型

有没有办法(natvie JS或JQuery)在元素列表上注册相同的事件类型?

如果可能的话,我想避免重复在几个元素上注册事件,一次一个.

理想(伪)代码:

$({elem1, elem2, elem3}).on("keyup", function() {
    // Do the same when each one of these elements gets focus
});
Run Code Online (Sandbox Code Playgroud)

javascript jquery events accessibility bind

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

jQuery off()和bind(this)

我试图从一个元素中删除一个事件处理程序,附加jQuery on()并删除它off().这通常会起作用,但在这种情况下它不起作用.

this.element.on('click', this.handler);
this.element.off('click', this.handler);
Run Code Online (Sandbox Code Playgroud)

这将工作,但在我的情况下,它不起作用,因为将范围绑定到处理程序.

this.element.on('click', this.handler.bind(this));
this.element.off('click', this.handler.bind(this));
Run Code Online (Sandbox Code Playgroud)

由于范围被绑定到处理程序,因此该off方法无法从该元素中分离事件.

我尝试过使用引用,如下所示:

var self = this;
this.element.on('click', this.handler.bind(self));
this.element.off('click', this.handler.bind(self));
Run Code Online (Sandbox Code Playgroud)

但没有运气......任何人都有想法解决这个问题?

javascript jquery bind

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

反应onClick事件产生:"未捕获的TypeError:无法读取未定义的属性",尽管绑定

我正在编写一个React脚本,它将<a />从之前定义的数组中呈现一堆元素.

...
render:
...
    var behaviourComponents = this.props.myObjectArray.map(function(element) {
                    return <a className="crumbFile" onClick={this._myFunction.bind(this,element.value1)}>{element.value2}</a>;
                });
    return (
...
<div>{behaviourComponents}</div>
...)
Run Code Online (Sandbox Code Playgroud)

当没有onClick函数调用时,这很好用.但是,当我得到错误时:"未捕获的TypeError:无法读取未定义的属性'_myFunction'".

这是特别奇怪的,因为我有一个组件就在它之前,onClick函数调用工作正常(<a class="btn header" style={buttonStyle} onClick={this._onLoad}>Load</a>),这使我认为这是一个范围问题,由于map()函数.但是,我使用了.bind(),所以我不太清楚这里有什么问题.

javascript bind reactjs

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