I found out, that the plugin worked, when there is only one, but not if there are many on a page.
so it was not enumerating a multiple result :) the plugin now works: (function($) { jQuery.fn.spinner = function() { return this.each(function() { // here we go! var input = $(this); var makeButton = function(cssClass, text) { return jQuery('<div class="' + cssClass + '"><span>' + text + '</span></div>'); }; var spin = function(value) { var val = parseInt(input.val()); var newValue = isNaN(val) ? 0 : val; if (newValue + value > -1) { newValue += value; } input.val(newValue); }; input.wrap('<div class="spinner"/>'); var spinDown = makeButton('spinDown', '-'); input.before(spinDown); spinDown.click(function() { return spin(-1); }); var spinUp = makeButton('spinUp', '+'); input.after(spinUp); spinUp.click(function() { return spin(1); }); }); }; })(jQuery); 2009/7/8 Jan Limpens <jan.limp...@gmail.com> > But that is not the problem. It is 100% ok to put a click event on an > anchor and expect it not to pass on the request, if you return false. > > For the sake of the argument, I changed the anchor to a div and I still get > no exception and it still does nothing. > > If I do this: > > spinDown.click(function() { > alert('down'); > return false; > //return spin(-1); > }); > > a click renders no alert. > so as the plugin does all the rest it is asked, it seems it does not attach > the click event in a way I would want it to. > > any ideas? > > 2009/7/8 MorningZ <morni...@gmail.com> > > >> I see this (stopping links in their tracks) a lot and it's puzzling, >> so i think: >> >> *if you do not want an <a> to actually follow a link, then don't use >> an <a>, use a <span> or something instead and use CSS to make it look >> like a link to the user* >> >> That will 100% solve all issues with a hyperlink acting like, well, a >> hyperlink :-) >> >> Problem with: >> return false; >> or >> e.preventDefault() >> >> is that if a JavaScript error happened before that, then either of >> those lines will never execute to prevent the browser from going >> wherever >> >> >> On Jul 8, 11:09 am, BaBna <thomas.na...@gmail.com> wrote: >> > I don't really see where your link is, but if you had .click(function >> > (e){e.preventDefault();} to your link, that should disable it. >> > >> > On Jul 8, 3:54 pm, Jan Limpens <jan.limp...@gmail.com> wrote: >> > >> > > hi there! >> > >> > > this plugin extends an input text with 2 links that increase or >> decrease >> > > it's value by 1. >> > > unfortunately, due to my dumbness it is not working as I would expect. >> > >> > > When one clicks at one of the links, the link works normally as a link >> would >> > > (making the request to ""). >> > >> > > Anybody could tell me what I am doing wrong - I am definitely >> suffering from >> > > jquery blindness here... >> > >> > > (function($) { >> > > jQuery.fn.spinner = function() { >> > > var input = $(this); >> > > var makeButton = function(cssClass, text) { >> > > return $('<a href="" class="' + cssClass + '"><span>' + >> text + >> > > '</span></a>'); >> > > }; >> > > var spin = function(value) { >> > > var val = parseInt(input.val()); >> > > var newValue = isNaN(val) >> > > ? 0 >> > > : val; >> > > if (newValue + value > -1) { >> > > newValue += value; >> > > } >> > > input.val(newValue); >> > > return false; >> > > }; >> > > input.wrap('<div class="spinner"/>'); >> > > var spinDown = makeButton('spinDown', '-'); >> > > input.before(spinDown); >> > > spinDown.click(function() { >> > > return spin(-1); >> > > }); >> > > var spinUp = makeButton('spinUp', '+'); >> > > input.after(spinUp); >> > > spinUp.click(function() { >> > > return spin(1); >> > > }); >> > > }; >> > >> > > })(jQuery); >> > >> > > <input type="text" id="spinMe" name="xxx" value="0"/> >> > >> > > $('#spinMe').spinner(); >> > >> > > -- >> > > Jan >> > > > > -- > Jan > -- Jan