From: DL on
Hi,

I have something like this:

var cb = new Ext.form.Combox( {
xtype: 'combo',
id: 'mybox'
....
});

which works just fine. However, in the later flow when the field
associated with the combox is no longer used I'd like to destroy the
box (it looks like cool effects).
The attempt of resetting the cb var to null did not help {cb=null} and
the attempt of removing the 'mybox' element didn't help neither
{var f = document.forms['myfrm']; var r =
document.getElementById('mybox'); f.removeChild(r);}

Simply put, it's like this:
Initially,
<input type="text" id="title"> {the combox here}
Later,
the <input type="text" id="title"> is removed or made invisible, so it
now looks like this
{the combox here}
and of course the above {the combox here} is unnecessary and it looks
bad.

Could you help? And please let me know if I haven't explained the
question clearly.

Thanks in advance.

P.S.
Testing browser is Firefox 3.5 and I'm using Firebug as well for
debugging.
From: Garrett Smith on
On 2010-06-19 10:08 AM, DL wrote:
> Hi,
>
> I have something like this:
>
> var cb = new Ext.form.Combox( {
> xtype: 'combo',
> id: 'mybox'
> ...
> });
>
> which works just fine. However, in the later flow when the field
> associated with the combox is no longer used I'd like to destroy the
> box (it looks like cool effects).

You're asking for help on what looks to be an Ext-js widget.

To answer that, one would need to be familiar with the API for that widget.

This NG is about discussing javascript, mainly, though not exclusively,
as it pertains to web scripting. That is not how to use a particular
library, but more on things such as found in the FAQ:

http://jibbering.com/faq/

- which is far from complete, but covers a few important core topics
such as Functions, Dates, and Numbers.

> The attempt of resetting the cb var to null did not help {cb=null} and
> the attempt of removing the 'mybox' element didn't help neither
> {var f = document.forms['myfrm']; var r =
> document.getElementById('mybox'); f.removeChild(r);}
>

Why would setting cb = null remove cause any elements to be removed?

Garrett
From: DL on
On Jun 19, 3:58 pm, Garrett Smith <dhtmlkitc...(a)gmail.com> wrote:
> On 2010-06-19 10:08 AM, DL wrote:
>
> > Hi,
>
> > I have something like this:
>
> > var cb = new Ext.form.Combox( {
> > xtype: 'combo',
> > id: 'mybox'
> > ...
> > });
>
....
> > The attempt of resetting the cb var to null did not help {cb=null} and
> > the attempt of removing the 'mybox' element didn't help neither
> > {var f = document.forms['myfrm']; var r =
> > document.getElementById('mybox'); f.removeChild(r);}
>
> Why would setting cb = null remove cause any elements to be removed?
>
> Garrett

You're right, I posted the js library forum as well this generic js NG
in the hope of a quicker solution... and yes, the attempt of setting
cb = null was silly.

From: SAM on
Le 6/19/10 7:08 PM, DL a �crit :
> Hi,
>
> I have something like this:
>
> var cb = new Ext.form.Combox( {
> xtype: 'combo',
> id: 'mybox'
> ...
> });
>
> which works just fine. However, in the later flow when the field
> associated with the combox is no longer used I'd like to destroy the
> box (it looks like cool effects).
> The attempt of resetting the cb var to null did not help {cb=null} and
> the attempt of removing the 'mybox' element didn't help neither
> {var f = document.forms['myfrm']; var r =
> document.getElementById('mybox'); f.removeChild(r);}

var r = document.getElementById('mybox'); r.parentNode.removeChild(r);
r = document.getElementById('title'); r.parentNode.removeChild(r);

and so on ..

function suppress(elemtId) {
elentId = typeof elemtId == 'string'?
document.getElementById(elemtId) : elemtId;
elemtId.parentNode.removeChild(elemtId);
}

suppress('title'); suppress('mybox');

or, if title is in 2nd position in the form named 'myfrm' :
suppress(document.forms['myfrm'][1]);
suppress(document.forms['myfrm'][1]);


--
sm