Yes and No as it then changes the "this" being passed to grabControl
(this) <-  "this" parameter should refer to the newly created textbox
object and doesn't.

any other suggestions?

thanks

On Jul 6, 7:37 pm, Fábio M. Costa <[email protected]> wrote:
>  'events': { 'click': function() {
>                            grabControl(this);
>                        }.bind(this)
>                    }
>
> this doesnt work?
>
> Fábio Miranda Costa
> Engenheiro de Computaçãohttp://meiocodigo.com
>
> On Mon, Jul 6, 2009 at 6:12 PM, Gafa <[email protected]> wrote:
>
> > var test= new Class({
> >    Implements: Options,
>
> >    options: {
> >        myOp: "DDD
> >    },
> >    initialize: function(options) {
> >        this.setOptions(options);
> >    },
> >   addControl: function(pCntrlType) {
> >        var obj
>
> >        switch (pCntrlType) {
> >            case "TXTB":
> >                obj = new Element('input', {
> >                    'id': 'textbox1',
> >                    'styles': {
> >                        position: 'absolute'
> >                    },
> >                    'events': { 'click': function() {
> >                            grabControl(this);
> >                        }
> >                    }
> >                }).inject($('tdMainCenterRight'));
> >                break;
> >        }
>
> >        this.makeElementDragable(obj);
> >    },
> >    grabControl: function(pEl) {
> >        //this.updateControlPosition(pEl);
>
> >        //set class varial to seleted control
>
> >    },
> >    makeElementDragable: function(pObj) {
>
> >        new Drag.Move(pObj, {
> >            container: $('tdMainCenterRight'),
> >            droppables: '#tdMainCenterRight',
> >            precalculate: 'true',
>
> >            onDrag: function(el, event) {
> >                //this.updateControlPosition(el);
> >            } .bind(this)
> >        });
> >    }
> > });
>
> > Problem is when I use this class and the grabControl function is
> > called from within the click event, it errors, I know I need to bind
> > the grabControl function from the class to the click event but I can't
> > figure it out.
>
> > Thanks

Reply via email to