RakeshMalik
Posts: 0
Joined: Tue Dec 22, 2015 4:47 am

Conditional mappings when looping over list items when invoking services?

I'm building a UI where I want to enable the user to select from a bunch of options, and save the selected items into a database. What's the best way to go about this? I'm right now trying to use jQuery selectors to pick out the questions from the list, and finding that there are a LOT of wrappers in the generated HTML code, so it's leading to rather convoluted selector (the way it's looking, it's going to be a series of nested selectors + loops, some pretty ridiculous code).
This is of course compounded by the fact that the editor has no introspection, so the only way to test the selector is to save the script + fire off a test, which is clunky.

So I'm wondering, is this the best way to go about this? I'm not even finding the IDs for the options I need to save, which would be problematic; I need those in order to save pointers. If there's a cleaner way to get this code in there, please let me know.

I haven't found a good way of looping over a set of options to build mappings, either. I can create a single mapping for each one when there' s a preset number of them (I know this isn't good engineering, but I haven't a better way to do this yet)... that doesn't work when the number of items to save is dynamic.

So, is there a way to create a pre-execute mapping for a service that loops over the items in a list, and performs the mapping + executes them depending on a condition? If that condition isn't met, skip that list entry and move on to the next one?

Thanks!

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

Conditional mappings when looping over list items when invoking services?

Hello Rakesh,

Could you clarify, do you wand to add related selectors to the page?

The best way is use AngularJS project and set all values to the one variable. After that you can use ng-options to set it's children's selectors.

If you want to use JQM project - you can set the same storage variable and run mapping for others selectors on change event from the previous one.

RakeshMalik
Posts: 0
Joined: Tue Dec 22, 2015 4:47 am

Conditional mappings when looping over list items when invoking services?

I want to be able to loop over items in a list, identify the selected ones, and invoke a service, pass it the list of selected items.

RakeshMalik
Posts: 0
Joined: Tue Dec 22, 2015 4:47 am

Conditional mappings when looping over list items when invoking services?

I'll see if I can do it via storage vars... that might enable me to do what I'm trying to do, unless in the mean time you give me a better suggestion. :)

Return to “Issues”