Problem switching data-verb attribute in object links

K.V.

Hello.

I have a function which replaces one object with a "stand-in" object. It has the same alias, but different display verbs.

Here is the code I'm using to switch the object's hyperlinks to handle the stand-in:

JS.eval ("$('.elementmenu').each(function(){if($(this).attr('data-elementid') == '"+this.name+"'){$(this).attr('data-elementid','"+this.standin.name+"').attr('data-verbs','Look at/Dismount');}	});")

This changes the data-elementid attribute for each link, but not the data-verbs attribute.

I can change each element's id attribute, and that works, too. It's just the data-verbs.

Is Quest binding each jjmenu to the link as they are created (or something)?


Check out the goings-on:


Even when I go into the console and change the data-verbs, the menu doesn't change.

Screenshot:

image


K.V.

I got it.

link = ProcessText("{object:"+this.standin.name+":"+this.standin.alias+"}")
JS.eval ("$('.elementmenu').each(function(){if($(this).attr('data-elementid') == '"+this.name+"'){$(this).html('"+link+"');}	});")

Nice one. Little inefficient though, I think?

Might be better to do something like:
JS.eval ("$(\".elementmenu[data-elementid='"+this.name+"']\").html('"+link+"');")

Not 100% sure on that.

(You can use $("[attributename='attributevalue']") as a selector; as far as I'm aware, it'll work for any attribute you can access with .attr(). Whether the attributevalue needs quotes seems to be a little wobbly, but I figure it's best to include them. You can also use ^= for "starts with", and I think it's $= and *= for "ends with" and "contains" string comparisons respectively)


K.V.

Sweet!

I'll try that! Thank you!


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums