Reputation: 413
I'm using ddSlick dropdown because it also has images. When you select a value nothing happens. How do I make it go to facebook.com or twitter.com if they are selected? Here is code:
var ddData = [
{
text: "Facebook",
value: "FB",
description: "Description with Facebook",
imageSrc: "http://dl.dropbox.com/u/40036711/Images/facebook-icon-32.png"
},
{
text: "Twitter",
value: "TWT",
description: "Description with Twitter",
imageSrc: "http://dl.dropbox.com/u/40036711/Images/twitter-icon-32.png"
}
];
$('#demoBasic').ddslick({
data: ddData,
width: 300,
imagePosition: "left",
selectText: "Select your favorite social network",
onSelected: function (data) {
console.log(data);
}
});
It uses these files: jquery 1.7.2. and ddslick.js
Upvotes: 2
Views: 756
Reputation: 767
kinda quick and dirty, but you can add additional attribute to the object that you pass:
var ddData = [
{
text: "Facebook",
value: "FB",
description: "Description with Facebook",
imageSrc: "http://dl.dropbox.com/u/40036711/Images/facebook-icon-32.png",
url:"http://www.facebook.com"
},
{
text: "Twitter",
value: "TWT",
description: "Description with Twitter",
imageSrc: "http://dl.dropbox.com/u/40036711/Images/twitter-icon-32.png",
url:"http://www.twitter.com"
}
];
$('#demoBasic').ddslick({
data: ddData,
width: 300,
imagePosition: "left",
selectText: "Select your favorite social network",
onSelected: function (data) {
window.location = data.selectedData.url;
}
});
Upvotes: 4