Page 1 of 2
Object id & actions
Posted: Mon Dec 23, 2013 7:49 pm
by Ilya
Probably this is a silly question, but I just can't get it.
I have created a todo app
todo app gets data from the list service to display items in the list
items in the list have checkboxes
once a person clicks checkbox, i want this to be transferred to the db.
4.1. to do this i created update task service and mapped its invocation on click on the checkbox.
The update doesn't happen.
What am I doing wrong? Maybe I'm missing local variables? if yes, then where should i have them? I mean that anyway the list_service returns everything from the db (including object ids), i display only task names, not object ids. Does this mean that object ids are 'lost'? So that i should clearly map them to something - not to loose them? If yes, then to what they should be mapped in my example?
Once again sorry for the silly question and also for not formulating it in a proper way - I just seem to miss something and just don't get what I'm missing.
Thank you.
Object id & actions
Posted: Mon Dec 23, 2013 7:58 pm
by Maryna Brodina
Hello! Map _id to hidden label to use it later in Update service.
Object id & actions
Posted: Mon Dec 23, 2013 8:11 pm
by Ilya
Maryna, thanks for the answer. I think I understand, but then how do I map the 'selected' state of checkbox to the update service? In the 'request' of the update service it is not possible to do the mapping for 'selected' checkbox.
Object id & actions
Posted: Mon Dec 23, 2013 10:00 pm
by Maryna Brodina
How do you store checkbox value in DB (what is the column type?). You can always use JS to retrieve data in format you need.
Object id & actions
Posted: Tue Dec 24, 2013 4:24 am
by Ilya
The column type is Boolean.
Object id & actions
Posted: Tue Dec 24, 2013 9:52 am
by Kateryna Grynko
Hi Ilya,
You can map checkbox value to request, and if it's selected then its value will be added to an array. Then go through this array and if the value exists then return true, else false.
Object id & actions
Posted: Thu Dec 26, 2013 5:17 pm
by Ilya
Katya, hi!
Sorry, this doesn't work:
http://appery.io/app/mobile-frame?src...
The only field that controls whether checkbox is displayed is 'Selected' and it's only available for mapping under Response tab (and in Request tab it's not available).
Maybe this is a bug - that 'selected' field for check-box is not available in the mapping under 'request'?
Object id & actions
Posted: Thu Dec 26, 2013 7:35 pm
by Maryna Brodina
Hello!
1) On element mobilecheckbox_9 use Value change event instead Click (Click doesn't work for checkbox on devices)
2) Don't invoke list_tasks_service right after task_update_service. It's better to invoke list_tasks_service on task_update_service success event
3) On Value change event on mobilecheckbox_9 element add JS:
prelocalStorage.setItem("newState", $(this).find("input").is(":checked"));/pre4) In task_update_service in request parameters mapping delete mapping to task_status parameter. Instead add in this parameter the following JSprereturn localStorage.getItem("newState");/pre
Object id & actions
Posted: Fri Dec 27, 2013 6:00 pm
by Ilya
Maryna, thank you very much for your reply. I gave it a try, but probably changed some code before and so the solution doesn't work.
What I think I would is try another example from tutorials and then return back to this one. Probably I'm missing some fundamental information on jquery + web services. Maybe you could suggest the place where to get it quick and fast or maybe you can give me some training (of course, i'd pay for it), say, via Skype?
Object id & actions
Posted: Fri Dec 27, 2013 7:55 pm
by maxkatz
There are many jQuery and jQuery Mobile resources available online.
If you want extra help from us, you may want to consider Appery.io Services: http://appery.io/services.