views:

25

answers:

2

Hello!

im processing link click events with mootools. in my html i have a links with the id of this pattern: toggle_NUMBER e.g. toggle_1 now i get the id with this peace of code

var id = $(this.get('id').replace(togglePrefix,emptyPrefix)); 

my problem starts now: i remove the prefix this way

var togglePrefix = 'toggle_', boxPrefix = 'page_', emptyPrefix = '';

so what should remain is a simple number like 1, 2 or 3. now i tried to increase this number by one

var id_new = parseInt(id)+1;

but this didnt work and i have no clue how to change it! Plz help!

A: 

Variable "id" is an object, because return value of $ function in mootools (and jQuery) is an object.

Try this:

var id_new = $(this).get('id').replace(togglePrefix, emptyPrefix) + 1;
fuwaneko
returns me 11 not 2 as intented.
Arwed
but this worked:var id_new = parseInt($(this).get('id').replace(togglePrefix, emptyPrefix)) + 1;
Arwed
thx for your help
Arwed
A: 

Did you try $(this).next() before you went hacking into the ID?

Chase
no sorry i heard for it sometimes but i can hardly find any documentation about .next() on mootools site
Arwed
that's because it's Element.getNext[1] in MooTools. Alas, I'm sure there's a better way to tackle your whole issue by refactoring the code.[1]: http://mootools.net/docs/core/Element/Element#Element:getNext
gonchuki