/    Sign up×
Community /Pin to ProfileBookmark

Basic JS newb question

Hey guys,

I’ve got a script that lists out data in rows (using <li> lists), if a user clicks on one of the entries it brings up a JS piemenu that has options like “Add to wishlist”, etc… Well, I would like to get rid of that piemenu and only have text links next to each entry that are commands to do the same thing as the pie menu, but eliminating the step of clicking to open the menu.

So one command in the menu it opens upon clicking is “addWishlist” – I would like this to be simply next to the list item, which gets put in the “entrytitle” div. Below is the code that generates the lists themselves. I would like to put an <a href=”javascript:addWishlist(target)”>Add to wishlist</a> link next to each one, but I really do not know what to put exactly, anything I’ve done with ‘prepend’ to get it to show up, ultimately makes an error when I click it.

Thanks

[CODE] if(col_title_array[part_num] != ”) {
var list = document.getElementById(‘entrylist’);
var newNode = document.createElement(“li”);
newNode.setAttribute(‘id’,col_array[part_num+1]);
newNode.className = “entry”;
$(newNode).hover( function(){$(this).addClass(“hover”);}, function(){$(this).removeClass(“hover”); });
div = document.createElement(“div”);
div.className = “entry-title”;
$(div).html( col_title_array[part_num] );
$(newNode).prepend( “<img src=’images/grip.gif’ class=’grip’/>” );
$(newNode).prepend( div ); [/CODE]

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@KorJul 23.2008 — It is not so "basic JS" as you said. The code does not use javascript native methods, thus I suspect you used a framework or library. Which one? JQuery? Prototype? Other?
Copy linkTweet thisAlerts:
@davidjnelsauthorJul 23.2008 — Jquery, sorry for not specifying.
Copy linkTweet thisAlerts:
@Jeff_MottJul 23.2008 — davidjnels, you haven't shown us enough to do anything with. It looks like a lot of the content comes from the value of [font=courier]col_title_array[part_num][/font], but we can't see what its value is. It'd be better if you could link to the whole, actual page.
Copy linkTweet thisAlerts:
@davidjnelsauthorJul 23.2008 — col_title_array[part_num] is a variable that changes depending on the specific <li> entry they click on.
×

Success!

Help @davidjnels spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.26,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...