PDA

View Full Version : Pass variable to popup window - need help



mobile207
23 Aug 2011, 1:56 PM
Trying to pass listing_id and listing_name to a modal/ popup window, not sure what I am doing wrong though. Any ideas?



var show_big_image = function(){ if (!this.popup) { this.popup = new Ext.Carousel({ floating: true, modal: true, centered: true, width: 312, height: 286, styleHtmlContent: false,
items: [{ html: '<img src="images/listings/' + this.listing_id + '_a.jpg">' }, { html: '<img src="images/listings/' + this.listing_id + '_b.jpg">' }, { html: '<img src="images/listings/' + this.listing_id + '_c.jpg">' } ], dockedItems: [{ dock: 'top', xtype: 'toolbar', style: 'font-size: 10pt;' }] }); } this.popup.show('pop'); }; function myFunction(e){alert('Hello');} this.tpl = "<div style='margin-top: -13px;margin-left: -3px;'>"+ "<table>"+ "<tr>"+ "<td style='width: 156px;'>"+ "<div style='margin-left: -5px; width: 142px;'><p class='details_listing_title'>{listing_name}</p>"+ "<p class='details_list_metadata' style='margin-top: -20px;'>{listing_address}<br/>{listing_city}</p></div>"+ "</td>"+ "<td style='width: 122px;''>"+ "<div class='image_wrapper'>"+ "<img src='images/listings/thumbs/{listing_id}.jpg' class='listing_image_main' id='show_gallery'>"+ "<div class='image_footer'><img src='icons/app_icons/plus_64.png' style='width: 7px;'> View Photos</div>"+ "</div>"+ "</td>"+ "</tr>"+ "</table>"+

"</div>"+ "</div></tpl>"; this.listeners = { body: { tap: show_big_image, delegate: '#show_gallery' } } MyApp.views.Details.superclass.initComponent.call(this); }});

mobile207
23 Aug 2011, 1:58 PM
Here is the correctly pasted code:


var show_big_image = function(){
if (!this.popup) {
this.popup = new Ext.Carousel({
floating: true,
modal: true,
centered: true,
width: 312,
height: 286,
styleHtmlContent: false,

items: [{
html: '<img src="images/listings/' + this.listing_id + '_a.jpg">'
},
{
html: '<img src="images/listings/' + this.listing_id + '_b.jpg">'
},
{
html: '<img src="images/listings/' + this.listing_id + '_c.jpg">'
}
],

dockedItems: [{
dock: 'top',
xtype: 'toolbar',
style: 'font-size: 10pt;'
}]


});
}
this.popup.show('pop');
};

function myFunction(e){
alert('Hello');
}



this.tpl = "<div style='margin-top: -13px;margin-left: -3px;'>"+
"<table>"+
"<tr>"+
"<td style='width: 156px;'>"+
"<div style='margin-left: -5px; width: 142px;'><p class='details_listing_title'>{listing_name}</p>"+
"<p class='details_list_metadata' style='margin-top: -20px;'>{listing_address}<br/>{listing_city}</p></div>"+
"</td>"+
"<td style='width: 122px;''>"+
"<div class='image_wrapper'>"+
"<img src='images/listings/thumbs/{listing_id}.jpg' class='listing_image_main' id='show_gallery'>"+
"<div class='image_footer'><img src='icons/app_icons/plus_64.png' style='width: 7px;'> View Photos</div>"+
"</div>"+
"</td>"+
"</tr>"+
"</table>"+


"</div>"+
"</div></tpl>";
this.listeners = {
body: {
tap: show_big_image,
delegate: '#show_gallery'
}
}
MyApp.views.Details.superclass.initComponent.call(this);
}
});

Mthor
24 Aug 2011, 3:18 PM
var listing_id = 'foo'

var win = new yourWindow({
listing_id: listing_id
});

win.show();

then in that window you should be able to call this.listing_id and you will get foo as the value

mobile207
24 Aug 2011, 4:34 PM
Great, thanks. I am able to get "foo" into the modal window now.

Is there a simple way to get a variable called listing_id out of a panel? Maybe calling it like on a webpage (get element by id or something?). My panel loads but I seem to only be able to access variables inside of this.tpl. I am able to access it inside by simply using {listing_id}.

Thanks for your help so far.

Mthor
26 Aug 2011, 9:42 PM
Got in late tonight. I will recheck and reply in the am