Looking for help replacing text with javascript/jquery in Axure? I’m trying to build an Axure plugin that searches for ‘/n’ within repeater data then replaces with html line break.
I’m not the most jQuery-literate person. This is what I have so far:
I’m prototyping the functionality locally then will build the plugin accordingly. So the interactions are currently on the repeater textbox and NOT Axure Share:
Haven’t done much AxQuery stuff in a while but I think the problem is that while AxQuery methods will work on all the widgets with the shared name (ex.: moveBy()) in this case you probably need to iterate through all the child elements that contain the actual text. if you look at the markup of an Axure widget you’ll see they’re made up of quite a few elements. There’s no AxQuery method available on the object that’s equivalent to a Set Text action as far as I can tell.
In this case you might have better luck just using jQuery to return a collection of nodes and then iterating through each one and updating its child element that contains the text.
$('[data-label=output-box]') will get you started. In other words, leave out the AxQuery and just do it the normal jQuery way.
So if I run something like:
javascript:void($axure(’@output-box’).text(‘Changed’))
it will change ALL text, but if I want to find/replace I’ll need to iterate through a collection one at a time? I guess that makes sense. I was just hoping for a simple find THIS and replace with THAT!
Ok, I see. Looks like it’s because the AxQuery object has a text() method that handles all that, but has not implemented a replace-like method that handles everything for you.
Rather than using plugins or jQuery to get line breaks in the repeater dataset, you can use the .replace( , ) method in the Set Text action for the repeater’s OnItemLoad:
OnItemLoad
Set text on [widget] equal to [[Item.ColumnName.replace(‘sometext’,’\n’)]]
where “sometext” is the text you include in the dataset specifically for line breaks, e.g. “< br >”
If you wanted to target text in the repeater only, you would change the line with the span selector to this, where repeaterName is the name of the repeater:
Fantastic! Thanks for figuring this one out. One peculiarity though, when I replace with a break (ie. \n, , etc.) it only shows as whitespace on the rendered page; however, it shows as line breaks in the actual HTML.