|
View:
New views
12 Messages
—
Rating Filter:
Alert me
|
|
|
Trying to assign events dynamically using delegates.I'm trying to create a new button here and attach an event to it, can
anyone tell me what I'm doing wrong? function create_part() { //get the part name part_name = canvas .main_tabs .buildout_editor .buildout_toolbar.toolbar_slider.parts_tab.new_part_field.text //add the part to the dom buildout_dp.addNode(part_name) //add it to the tab slider canvas.main_tabs.buildout_editor.buildout_ts.addItem(part_name) //wipe out the text field canvas .main_tabs .buildout_editor .buildout_toolbar.toolbar_slider.parts_tab.new_part_field.text = ''" //create the delete button var delete_button = new lz .button(canvas.main_tabs.buildout_editor.buildout_ts.getItem(part_name)) delete_button.setAttribute('text','Delete') //create the delegate if ( typeof delete_button.del == "undefined" ) { delete_button.del = new LzDelegate( delete_button, "test2"); } //assign the event delete_button.del.register( delete_button, "onclick" ); } Regards, Ken |
|
|
Re: Trying to assign events dynamically using delegates.What is the error? Your test2 method is never getting called? Where is
the "test2" method being declared on the button class? Don't you need a subclass of button, in order to define your method on it? On Mon, Jul 21, 2008 at 2:40 PM, Kenneth Miller <xkenneth@...> wrote: > I'm trying to create a new button here and attach an event to it, can anyone > tell me what I'm doing wrong? > > function create_part() { > > //get the part name > part_name = > canvas.main_tabs.buildout_editor.buildout_toolbar.toolbar_slider.parts_tab.new_part_field.text > > //add the part to the dom > buildout_dp.addNode(part_name) > > //add it to the tab slider > canvas.main_tabs.buildout_editor.buildout_ts.addItem(part_name) > > //wipe out the text field > > canvas.main_tabs.buildout_editor.buildout_toolbar.toolbar_slider.parts_tab.new_part_field.text > = ''" > > //create the delete button > var delete_button = new > lz.button(canvas.main_tabs.buildout_editor.buildout_ts.getItem(part_name)) > delete_button.setAttribute('text','Delete') > > //create the delegate > if ( typeof delete_button.del == "undefined" ) { > delete_button.del = new LzDelegate( delete_button, "test2"); > } > > //assign the event > delete_button.del.register( delete_button, "onclick" ); > > } > > Regards, > Ken > > -- Henry Minsky Software Architect hminsky@... |
|
|
Re: Trying to assign events dynamically using delegates.You can call a method on another object, using a delegate, but you'd
have to create the delegate to point to your object e.g., new LzDelegate(yourinstance, "test2") Your delegate was created to call the test2 method on your button instance. ... On Mon, Jul 21, 2008 at 2:59 PM, Henry Minsky <hminsky@...> wrote: > What is the error? Your test2 method is never getting called? Where is > the "test2" method being declared on > the button class? Don't you need a subclass of button, in order to > define your method on it? > > > On Mon, Jul 21, 2008 at 2:40 PM, Kenneth Miller <xkenneth@...> wrote: >> I'm trying to create a new button here and attach an event to it, can anyone >> tell me what I'm doing wrong? >> >> function create_part() { >> >> //get the part name >> part_name = >> canvas.main_tabs.buildout_editor.buildout_toolbar.toolbar_slider.parts_tab.new_part_field.text >> >> //add the part to the dom >> buildout_dp.addNode(part_name) >> >> //add it to the tab slider >> canvas.main_tabs.buildout_editor.buildout_ts.addItem(part_name) >> >> //wipe out the text field >> >> canvas.main_tabs.buildout_editor.buildout_toolbar.toolbar_slider.parts_tab.new_part_field.text >> = ''" >> >> //create the delete button >> var delete_button = new >> lz.button(canvas.main_tabs.buildout_editor.buildout_ts.getItem(part_name)) >> delete_button.setAttribute('text','Delete') >> >> //create the delegate >> if ( typeof delete_button.del == "undefined" ) { >> delete_button.del = new LzDelegate( delete_button, "test2"); >> } >> >> //assign the event >> delete_button.del.register( delete_button, "onclick" ); >> >> } >> >> Regards, >> Ken >> >> > > > > -- > Henry Minsky > Software Architect > hminsky@... > -- Henry Minsky Software Architect hminsky@... |
|
|
Re: Trying to assign events dynamically using delegates.All,
Here's the error: ERROR @lz/button.lzx#35: Invalid delegate: button text=Delete.test2 => «undefined» (must be a Function) Regards, Ken On Jul 21, 2008, at 2:00 PM, Henry Minsky wrote:
|
|
|
Re: Trying to assign events dynamically using delegates.Do you have a "test2" method defined on button? It would seem to me
that you don't, because you're instantiating it right there, and there is no test2 method defined in the lz button component class, that I know of.. On Mon, Jul 21, 2008 at 4:06 PM, Kenneth Miller <xkenneth@...> wrote: > All, > Here's the error: ERROR @lz/button.lzx#35: Invalid delegate: button > text=Delete.test2 => «undefined» (must be a Function) > Regards, > Ken > On Jul 21, 2008, at 2:00 PM, Henry Minsky wrote: > > You can call a method on another object, using a delegate, but you'd > have to create the delegate to point to your object > > e.g., > > new LzDelegate(yourinstance, "test2") > > Your delegate was created to call the test2 method on your button instance. > ... > > > > On Mon, Jul 21, 2008 at 2:59 PM, Henry Minsky <hminsky@...> > wrote: > > What is the error? Your test2 method is never getting called? Where is > > the "test2" method being declared on > > the button class? Don't you need a subclass of button, in order to > > define your method on it? > > > On Mon, Jul 21, 2008 at 2:40 PM, Kenneth Miller <xkenneth@...> wrote: > > I'm trying to create a new button here and attach an event to it, can anyone > > tell me what I'm doing wrong? > > function create_part() { > > //get the part name > > part_name = > > canvas.main_tabs.buildout_editor.buildout_toolbar.toolbar_slider.parts_tab.new_part_field.text > > //add the part to the dom > > buildout_dp.addNode(part_name) > > //add it to the tab slider > > canvas.main_tabs.buildout_editor.buildout_ts.addItem(part_name) > > //wipe out the text field > > canvas.main_tabs.buildout_editor.buildout_toolbar.toolbar_slider.parts_tab.new_part_field.text > > = ''" > > //create the delete button > > var delete_button = new > > lz.button(canvas.main_tabs.buildout_editor.buildout_ts.getItem(part_name)) > > delete_button.setAttribute('text','Delete') > > //create the delegate > > if ( typeof delete_button.del == "undefined" ) { > > delete_button.del = new LzDelegate( delete_button, "test2"); > > } > > //assign the event > > delete_button.del.register( delete_button, "onclick" ); > > } > > Regards, > > Ken > > > > > > -- > > Henry Minsky > > Software Architect > > hminsky@... > > > > > -- > Henry Minsky > Software Architect > hminsky@... > > -- Henry Minsky Software Architect hminsky@... |
|
|
Asynchronous mess with datasets.Hi all,
I have a form with a grid on it. This grid has a dataset pointing to a PHP script, lets call it grid_dataset. When the user clicks on the edit and new buttons, there is a pop-up window with a second dataset I use for updates/inserts, lets call it update_dataset. The data is being inserted/edited ok on the database, but the grid_dataset.doRequest() I fire just befor I hide the insert/edit window seems to be finishing before update_dataset.doRequest(), and the grid is not showing the updated/inserted values. What should I do to ensure grid_dataset.doRequest() will fire after update_dataset.doRequest()? Should I use other approach? Thanks in advance, -- Paulo |
|
|
Re: Trying to assign events dynamically using delegates.Why does it have to be defined "on" the button, it's defined in the source, which you can view here. Thanks for your time.
buildoutbuilder.lzx is the file you're looking for. Thanks again! Regards, Ken On Jul 21, 2008, at 3:18 PM, Henry Minsky wrote:
|
|
|
Re: Asynchronous mess with datasets.Hi Paulo,
Can you use the ondata() handler from update_dataset to trigger the grid_dataset request? Dave On Jul 21, 2008, at 1:46 PM, Paulo Scardine wrote: > Hi all, > > I have a form with a grid on it. This grid has a dataset pointing to > a PHP script, lets call it grid_dataset. When the user clicks on the > edit and new buttons, there is a pop-up window with a second dataset > I use for updates/inserts, lets call it update_dataset. > > The data is being inserted/edited ok on the database, but the > grid_dataset.doRequest() I fire just befor I hide the insert/edit > window seems to be finishing before update_dataset.doRequest(), and > the grid is not showing the updated/inserted values. > > What should I do to ensure grid_dataset.doRequest() will fire after > update_dataset.doRequest()? Should I use other approach? > > Thanks in advance, > -- > Paulo |
|
|
Re: Asynchronous mess with datasets.Paulo Scardine escreveu:
> Hi all, > > I have a form with a grid on it. This grid has a dataset pointing to a > PHP script, lets call it grid_dataset. When the user clicks on the > edit and new buttons, there is a pop-up window with a second dataset I > use for updates/inserts, lets call it update_dataset. > > The data is being inserted/edited ok on the database, but the > grid_dataset.doRequest() I fire just befor I hide the insert/edit > window seems to be finishing before update_dataset.doRequest(), and > the grid is not showing the updated/inserted values. > > What should I do to ensure grid_dataset.doRequest() will fire after > update_dataset.doRequest()? Should I use other approach? > grid_dataset.doRequest() from this handler. > Thanks in advance, > -- > Paulo |
|
|
Re: Trying to assign events dynamically using delegates.I think Henry's suggesting you change
delete_button.del = new LzDelegate( delete_button, "test2"); to delete_button.del = new LzDelegate( canvas, "test2"); The first parameter tells the delegate on which object it should run "test2". Obviously lz.button doesn't have one of those...your canvas does. Cary Kenneth Miller wrote: > Why does it have to be defined "on" the button, it's defined in the > source, which you can view here. Thanks for your time. > > http://github.com/xkenneth/buildoutbuilder/tree/master/buildoutbuilder.laszlo/src > > buildoutbuilder.lzx is the file you're looking for. > > Thanks again! > > Regards, > Ken > > On Jul 21, 2008, at 3:18 PM, Henry Minsky wrote: > >> Do you have a "test2" method defined on button? It would seem to me >> that you don't, because you're instantiating >> it right there, and there is no test2 method defined in the lz button >> component class, that I know of.. >> >> >> On Mon, Jul 21, 2008 at 4:06 PM, Kenneth Miller <xkenneth@... >> <mailto:xkenneth@...>> wrote: >>> All, >>> Here's the error: ERROR @lz/button.lzx#35: Invalid delegate: button >>> text=Delete.test2 => «undefined» (must be a Function) >>> Regards, >>> Ken >>> On Jul 21, 2008, at 2:00 PM, Henry Minsky wrote: >>> >>> You can call a method on another object, using a delegate, but you'd >>> have to create the delegate to point to your object >>> >>> e.g., >>> >>> new LzDelegate(yourinstance, "test2") >>> >>> Your delegate was created to call the test2 method on your button >>> instance. >>> ... >>> >>> >>> >>> On Mon, Jul 21, 2008 at 2:59 PM, Henry Minsky >>> <hminsky@... <mailto:hminsky@...>> >>> wrote: >>> >>> What is the error? Your test2 method is never getting called? Where is >>> >>> the "test2" method being declared on >>> >>> the button class? Don't you need a subclass of button, in order to >>> >>> define your method on it? >>> >>> >>> On Mon, Jul 21, 2008 at 2:40 PM, Kenneth Miller <xkenneth@... >>> <mailto:xkenneth@...>> wrote: >>> >>> I'm trying to create a new button here and attach an event to it, >>> can anyone >>> >>> tell me what I'm doing wrong? >>> >>> function create_part() { >>> >>> //get the part name >>> >>> part_name = >>> >>> canvas.main_tabs.buildout_editor.buildout_toolbar.toolbar_slider.parts_tab.new_part_field.text >>> >>> //add the part to the dom >>> >>> buildout_dp.addNode(part_name) >>> >>> //add it to the tab slider >>> >>> canvas.main_tabs.buildout_editor.buildout_ts.addItem(part_name) >>> >>> //wipe out the text field >>> >>> canvas.main_tabs.buildout_editor.buildout_toolbar.toolbar_slider.parts_tab.new_part_field.text >>> >>> = ''" >>> >>> //create the delete button >>> >>> var delete_button = new >>> >>> lz.button(canvas.main_tabs.buildout_editor.buildout_ts.getItem(part_name)) >>> >>> delete_button.setAttribute('text','Delete') >>> >>> //create the delegate >>> >>> if ( typeof delete_button.del == "undefined" ) { >>> >>> delete_button.del = new LzDelegate( delete_button, "test2"); >>> >>> } >>> >>> //assign the event >>> >>> delete_button.del.register( delete_button, "onclick" ); >>> >>> } >>> >>> Regards, >>> >>> Ken >>> >>> >>> >>> >>> >>> -- >>> >>> Henry Minsky >>> >>> Software Architect >>> >>> hminsky@... <mailto:hminsky@...> >>> >>> >>> >>> >>> -- >>> Henry Minsky >>> Software Architect >>> hminsky@... <mailto:hminsky@...> >>> >>> >> >> >> >> -- >> Henry Minsky >> Software Architect >> hminsky@... <mailto:hminsky@...> > |
|
|
Re: Trying to assign events dynamically using delegates.I think you are misunderstanding delegate: http://labs.openlaszlo.org/trunk-nightly/docs/reference/LzDelegate.html
If test2 is a method on the canvas and you want to invoke it when button is clicked, you would say: new LzDelegate(canvas, 'test2', delete_button, "onclick") On 2008-07-21, at 16:49EDT, Kenneth Miller wrote: > Why does it have to be defined "on" the button, it's defined in the > source, which you can view here. Thanks for your time. > > http://github.com/xkenneth/buildoutbuilder/tree/master/buildoutbuilder.laszlo/src > > buildoutbuilder.lzx is the file you're looking for. > > Thanks again! > > Regards, > Ken > > On Jul 21, 2008, at 3:18 PM, Henry Minsky wrote: > >> Do you have a "test2" method defined on button? It would seem to me >> that you don't, because you're instantiating >> it right there, and there is no test2 method defined in the lz button >> component class, that I know of.. >> >> >> On Mon, Jul 21, 2008 at 4:06 PM, Kenneth Miller >> <xkenneth@...> wrote: >>> All, >>> Here's the error: ERROR @lz/button.lzx#35: Invalid delegate: >>> button >>> text=Delete.test2 => «undefined» (must be a Function) >>> Regards, >>> Ken >>> On Jul 21, 2008, at 2:00 PM, Henry Minsky wrote: >>> >>> You can call a method on another object, using a delegate, but >>> you'd >>> have to create the delegate to point to your object >>> >>> e.g., >>> >>> new LzDelegate(yourinstance, "test2") >>> >>> Your delegate was created to call the test2 method on your button >>> instance. >>> ... >>> >>> >>> >>> On Mon, Jul 21, 2008 at 2:59 PM, Henry Minsky <hminsky@... >>> > >>> wrote: >>> >>> What is the error? Your test2 method is never getting called? >>> Where is >>> >>> the "test2" method being declared on >>> >>> the button class? Don't you need a subclass of button, in order to >>> >>> define your method on it? >>> >>> >>> On Mon, Jul 21, 2008 at 2:40 PM, Kenneth Miller >>> <xkenneth@...> wrote: >>> >>> I'm trying to create a new button here and attach an event to it, >>> can anyone >>> >>> tell me what I'm doing wrong? >>> >>> function create_part() { >>> >>> //get the part name >>> >>> part_name = >>> >>> canvas >>> .main_tabs >>> .buildout_editor >>> .buildout_toolbar.toolbar_slider.parts_tab.new_part_field.text >>> >>> //add the part to the dom >>> >>> buildout_dp.addNode(part_name) >>> >>> //add it to the tab slider >>> >>> canvas.main_tabs.buildout_editor.buildout_ts.addItem(part_name) >>> >>> //wipe out the text field >>> >>> canvas >>> .main_tabs >>> .buildout_editor >>> .buildout_toolbar.toolbar_slider.parts_tab.new_part_field.text >>> >>> = ''" >>> >>> //create the delete button >>> >>> var delete_button = new >>> >>> lz >>> .button >>> (canvas.main_tabs.buildout_editor.buildout_ts.getItem(part_name)) >>> >>> delete_button.setAttribute('text','Delete') >>> >>> //create the delegate >>> >>> if ( typeof delete_button.del == "undefined" ) { >>> >>> delete_button.del = new LzDelegate( delete_button, "test2"); >>> >>> } >>> >>> //assign the event >>> >>> delete_button.del.register( delete_button, "onclick" ); >>> >>> } >>> >>> Regards, >>> >>> Ken >>> >>> >>> >>> >>> >>> -- >>> >>> Henry Minsky >>> >>> Software Architect >>> >>> hminsky@... >>> >>> >>> >>> >>> -- >>> Henry Minsky >>> Software Architect >>> hminsky@... >>> >>> >> >> >> >> -- >> Henry Minsky >> Software Architect >> hminsky@... > |
|
|
Re: Trying to assign events dynamically using delegates.All,
Awesome! Works! Thanks everyone! Regards, Ken On Jul 21, 2008, at 4:22 PM, P T Withington wrote:
|
| Free Forum Powered by Nabble | Forum Help |