-
25 Jul 2008 4:22 PM #1
component ownerCt property always undefined ..
component ownerCt property always undefined ..
Im killing my brain already for 3 hours just for getting component's parent element .
So imagine that there is panel .
1) Then its getting updated through ajax with text and span elements .
2) Every span element gets click event :
3)After click event get fired, im creating input field(applying it to related span - target) and combobox component(applyed to this input)Code:var spans = Ext.query("#center span"); for(var i=0; i<spans.length; i++) { Ext.EventManager.addListener(spans[i], 'click', handle_span_click); }
So the problem is - how can i get parent element ( it should be span element ) of combobox, after it's select event is fired ?
Can anyone gimme some help with this ?Code:var handle_select_change = function handle_select_change(cmb, rcd, inx) { alert(cmb.ownerCt); <-- undefined };
The main thing that i want is to replace this combobox with selected value in span element, where its rendered to .
Also is there any way to get input field , that combobox applyed to ?
Hope on your answers
-
25 Jul 2008 7:05 PM #2Sencha - Sales Team
- Join Date
- Mar 2007
- Location
- Melbourne, Australia (aka GMT+10)
- Posts
- 738
- Vote Rating
- 6
why don't you just hide the combobox and show a span with the value from the combobox in it?
Check out SenchaWorld.com for articles, screencasts, conference videos and more.
Sencha Technical Training : Asia Pacific Region
Code Validation : JSLint | JSONLint | JSONPLint
-
25 Jul 2008 7:30 PM #3
Are you inserting the combo box into any Ext container? If you're just rendering/applying it to a page, it won't have an Ext container.
If you want to get the parent ELEMENT:
Code:var p = cmb.getEl().parent();
Evan Trimboli
Sencha Developer
Twitter - @evantrimboli
Don't be afraid of the source code!
-
26 Jul 2008 4:44 PM #4
In order to show span - i need to get its link first ;-)
evant,
Thx! Thats exactly what i was looking for .
------------------------------------------------------------
And i have last , but also important problem , about combobox and floating .
So imagine returning data :
After im rendering combobox to this span, result become :Code:a b c <span>d</span> e f <span>g</span> h"
I cant understand, why combobox make position to change, as its parent span is "inline" ? Whats the problem? ((Code:a b c e <span><combobox>d</combobox></span> f h <span><combobox>g</combobox></span>"
-
27 Jul 2008 7:15 AM #5
-
27 Jul 2008 7:20 AM #6
How are we supposed to know? You haven't posted the relevant code.
Evan Trimboli
Sencha Developer
Twitter - @evantrimboli
Don't be afraid of the source code!
-
27 Jul 2008 8:01 AM #7
Ok, sorry . But i think its not code's problem .
So here i got reponse with text and spans , they are showed inline, everything ok .Code:// Success action form response success: function(form, action){ var response_obj = Ext.util.JSON.decode(action.response.responseText); document.getElementById('center').innerHTML = response_obj.response_article.article; // its text + spans var spans = Ext.query("#center span"); for(var i=0; i<spans.length; i++) { Ext.EventManager.addListener(spans[i], 'click', handle_span_click); Ext.DomHelper.applyStyles(spans[i], 'background-color: #90ded2;'); } Ext.getCmp('center_panel').body.highlight('#c3daf9', {block: true}); } });
So now i have like this:
"word1 word2 <span>word3</span> word4
word5 <span>word6</span> word7" .
So now if you click span - combobox appear .Code:// handle span click event function var handle_span_click = function handle_span_click(ev, target) { if(target.getElementsByTagName('input').length < 1) { // here im making store, dont show prev_value = target.innerHTML; target.innerHTML = ''; var input = new Ext.Element(document.createElement('input')); input.appendTo(target); var combo = new Ext.form.ComboBox({ store: store, displayField: 'syns', typeAhead: true, mode: 'local', triggerAction: 'all', value: prev_value, selectOnFocus:true, applyTo: input, listeners: { select: handle_select_change } }); } };
But now data , that i showed before, will look like:
"word1 word2 word4
<span>word3</span> word5 word7
<span>word6</span> " .
And i cant understand, why do they float left .
All i need is : 1) appear combobox normally, as span 2) after select event got fired - delete combobox and update span with selected value ( and also save all markup .. )
Thx


Reply With Quote



