Positioning Widget based on auto-fit box content (width) / javascript

I want a widget to move/position at a particular pixel point based on the width of an auto-fit text box after text in it changes.

I’ve used the following as a starting point:
https://d2d2wdgkcw7kfa.cloudfront.net/original/3X/3/a/3a684dff8b1add1700009a7f840c83ce3344b3ba.rp

I’m discovering a problem, when it comes to this javascript command:

javascript:void($axure.setGlobalVariable(“newHeight”,$( “[data-label=headline] .text”).height()));

It works fine, as in the demo, on a box with autofit height, showing the new height value once the height changes. However, once I change the autofit element from height to width, and change the js command to “data-label=headline] .text”).width())); it does not return the new box width value, only the original width.

Any ideas why this might be so?
Thanks

You’re missing a double quotation mark after text and an opening square bracket before data.

Also, are there any errors in the browser console? Because this will probably throw an error.

Thanks… Actually that looks like it is just a typo in the forum post, not in my code (I’ll correct it). It is not throwing an error… what it’s doing when I ask for the pixel value of the text box once the text inside it has changed is that only returns the pixel value of the original width. It’s weird as it does not do this when I set it to height.

Is the width of the element in the DOM actually changing? Perhaps it’s working correctly and your expectation are incorrect?

Yes, the text box works just fine, it is just the value it returns that doesn’t match. I can upload the .rp file if that’s useful.