PDA

View Full Version : problem with passing a variable



koolaid1551
29 Jul 2011, 4:54 AM
So I am not really sure how to go about passing a variable from a data store to a function for the selected item.



myapp.views.SetDetail = Ext.extend(Ext.Panel, {

scroll: "vertical",
layout: {
type: "vbox",
align: "stretch"
},
initComponent: function () {
this.dockedItems = [{
xtype: "toolbar",
title: this.record.data.name,
items: [{
ui: "back",
text: "Back",
scope: this,
handler: function () {
this.ownerCt.setActiveItem(this.prevCard, {
type: "slide",
reverse: true,
scope: this,
after: function () {
this.destroy()
}
})
}
}]
}];
this.items = [{
styleHtmlContent: true,
tpl: playerHtml,
data: this.record.data,

}];

myapp.views.SetDetail.superclass.initComponent.call(this)
},

fireEvent: function () {
$("#jquery_jplayer_1").jPlayer({
ready: function () {
$(this).jPlayer("setMedia", {
// this works perfectly fine when I hard code a url in here such as (mp3: "http://mysite.com/song.mp3")
mp3: murl
});
},
swfPath: "js",
supplied: "mp3",
backgroundColor: "#FFFFFF"
});
}
});
Ext.reg("setdetail", myapp.views.SetDetail);


My problem is that I need to get 'murl' to equal the url from the current item selected. So it would be something like 'murl = this.record.data.url', which isn't working for me any ideas. I think it has something to do with murl being a private variable because I can get an alert to show with the url if I put in the items or docked items but when i put it after in my function it doesn't return anything. Any ideas on how I should go about fixing this issue?

koolaid1551
29 Jul 2011, 8:19 AM
im pretty sure if i do something like this it could work but i can't find enough documentation to get the format right.



mp3: myapp.views.SetDetail.dockedItems.items[0].getItem(url)


Any thoughts/ideas

koolaid1551
29 Jul 2011, 10:51 AM
I got it to work by using "this.record.data.url" but i had to set a variable first and then call the variable when defining the mp3.



fireEvent: function () {
var murl = this.record.data.url;
$("#jquery_jplayer_1").jPlayer({
ready: function () {
$(this).jPlayer("setMedia", {
mp3: murl
});
},
swfPath: "js",
supplied: "mp3"
});
}