BindAsEventListener不返回Prototype中的Observe元素

时间:2010-09-24 00:57:16

标签: javascript prototypejs

    var Generic_Large_Blue = new Element('div', { 'id': 'divZoltarSubmit_', 'class': 'Generic_Large_Blue Blue_' + placeholder });
    var Generic_Large_Blue_Left = new Element('div', { 'class': 'Generic_Large_Blue_Left' });
    var Generic_Large_Blue_Middle = new Element('div', { 'class': 'Generic_Large_Blue_Middle' });
    var Generic_Large_Blue_Span = new Element('span').update("Submit");
    var Generic_Large_Blue_Right = new Element('div', { 'class': 'Generic_Large_Blue_Right' });

    //event on submit Click

    Event.observe(Generic_Large_Blue, 'click', function(event) {
        moZoltarCurrent.evt_ZoltarOnSubmit.bindAsEventListener(this,Item_TextArea, PriceInBox,event);            
    });

//this function is called when the submit button is clicked
evt_ZoltarOnSubmit: function(e) {

    var sourceElement = Event.element(e);
    var args = $A(arguments);
}

我在Generic_Large_Blue上有点击事件,但源元素已返回Generic_Large_Blue_LeftGeneric_Large_Blue_MiddleGeneric_Large_Blue_Right

取决于点击位置它不返回观察元素

请帮帮我

1 个答案:

答案 0 :(得分:0)

仔细查看其documentation pagebindAsEventListener的示例。 bindAsEventListener返回函数,不调用函数。这是一个很好的代码:

Event.observe(Generic_Large_Blue, 'click', moZoltarCurrent.evt_ZoltarOnSubmit.bindAsEventListener(this, Item_TextArea, PriceInBox));

PS:下次检查你的代码是否正确显示(你没有指定代码是什么块,所以格式化了。)