I'm trying to change the voting widget to a span of text rather than an image and I'm stumped.
Ideally I'd want something like on flag module -- "vote for this post", for example.

The JS removes the contents of the widget and if I comment that out, I get the "An HTTP error" JS error popup when I try to vote.

Comments

joachim’s picture

To add more detail -- the problem is basically that the HTML in the theme function and the accompanying Javascript are too tightly connected.
If you try to do your own thing in the theme, it breaks. Here's what the js does:


$('span.vote-up-inact, span.vote-down-inact, span.vote-up-act, span.vote-down-act').each(function () {
// so we're selecting the SPANs....

// Read in the path to the PHP handler
uri = $(this).attr('title');
// the URI was spoofed in by the theme as a TITLE. weird.

// Remove the title, so no tooltip will display
$(this).removeAttr('title');
// now kill it

// remove href link
$(this).html('');
// now kill the ENTIRE CONTENTS of the span!

// Create an object with this uri. Because
// we feed in the span as an argument, we'll be able
// to attach events to this element.
if (!vdb[uri]) {
vdb[uri] = new Drupal.VDB(this, uri);
}
// and now totally rejig it.

The voting widget shouldn't rely on JS to produce something, and it shouldn't kill what's there.

marvil07’s picture

Status: Active » Closed (won't fix)

Please take a look to the update on the project page, now 5.x is not-really-maintained.

If you think your question is still applicably to the last recommended version(6.x-2.x) please move the version accordingly and reopen it.

sreynen’s picture

Version: 5.x-1.0 » 6.x-2.0-rc1
Status: Closed (won't fix) » Active

This is still an issue in 6.x. $(this).html(''); doesn't do what the comment right above says it should do (remove a specific tag). I suggest replacing that with a more specific $(this).find('a.vote-up-inact, a.vote-down-inact').remove();

marvil07’s picture

Status: Active » Closed (won't fix)

sorry, the recommended way to do such a customization is make your own widget(not use js to change the widget), that process is extensively documented on WIDGETAPI.txt