PDA

View Full Version : extjs.com right top corner slider popup database



robin30
11 Nov 2009, 4:38 PM
hi all,

i like the little slider popup on the extjs.com main website.

but i want the lines come from my database.
so far i have this:

var productstore = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
url: 'database.php'
}),

baseParams:{task: "getallproducts"},
autoLoad:true,
reader: new Ext.data.JsonReader({
root: 'results',
totalProperty: 'total',
id: 'id'
},['id','name','price','description','image', 'itemnumber'])
});
productstore.on('load', function(){
for(i = 0; i< productstore.getCount(); i++){
deals1 = productstore.getAt(i).data.name+' - $'+productstore.getAt(i).data.price;
Ext.each(deals1, function(person, index) {
totalmsgs = {text: '<img src="images/new.png"> '+ person, url:''}
});
}

var msgs = [
{text: '&raquo; Welcome to RM Computers', url:''},
{text: '&raquo; Better Service, Better Deals', url:''},
totalmsgs,
];
var msgs = msgs;
var msgIndex = 0;
var msg = Ext.get('msg'),
msgInner = Ext.get('msg-inner'),
active = null;

if (msgInner) {
msgInner.addClassOnOver('msg-over');
};

if (msg) {
// msg.on('click', function(){
// window.location = active.url;
// });
}

function doUpdate(){
if (msgInner) {
msgInner.update(active.text);
}
if (msg) {
msg.slideIn('t');
}
}

function showMsg(index){
if(msgInner && !msgInner.hasClass('msg-over')) {
active = msgs[index];
if(msg && msg.isVisible()){
msg.slideOut('t', {callback: doUpdate});
}else{
doUpdate();
}
}
}

setInterval(function(){
msgIndex = msgs[msgIndex+1] ? msgIndex+1 : 0;
showMsg(msgIndex);
}, 5000);
showMsg(0);
});

but only 1 line shows up.

if i do this

for(i = 0; i< productstore.getCount(); i++){
deals1 = productstore.getAt(i).data.name+' - $'+productstore.getAt(i).data.price;
Ext.each(deals1, function(person, index) {
alert(person);
});
}

3 alert boxes will show up with the with each an item from my database (only have 3 items in there).

i do believe it has something to do with the missing ',' at the end of this line:

totalmsgs = {text: '<img src="images/new.png"> '+ person, url:''}

but how do i get it there, i can't just put it at the end of the line, tried everything between " ", nothing seems to work.

any help is appreciated,

regards,
Robin30