Clement Yew
Posts: 0
Joined: Tue Jun 16, 2015 8:40 am

Toggle Component jquery - Update database upon value change

I have a question...

I'm using a toggle component in jquery to show the boolean value from a database. That's working fine.

What I want is, when user clicks on the 'toggle', I want the database value to be updated live.

The problem is, I'm not sure how to go about this.
Basically what I want is :

  1. User clicks on a toggle

  2. Toggle new value will be updated to the corresponding database row. (live update)

    *refer to image below

    Image

    thanks.

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

Toggle Component jquery - Update database upon value change

Hello,

Sure, it is possible. You have to add mappings from these toggles to the request parameters of the update service

Clement Yew
Posts: 0
Joined: Tue Jun 16, 2015 8:40 am

Toggle Component jquery - Update database upon value change

Any examples on this?

How do I get the corresponding row that the user clicks on the toggle?
Because the update service requires the row id as a parameter.

Right now, what I'm trying is upon the list service return result, i put in the javascript for the toggle in mapping :

element.on("value_change", function () {
Apperyio.storage.selectedLocation.update("$['id']", value.id);
Apperyio.storage.selectedLocation.update("$['name']", value.name);
Apperyio.storage.selectedLocation.update("$['showPromo']", value.showPromo);
Apperyio('testLbl').text(value._id);
});

But it doesn't seem to work.

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

Toggle Component jquery - Update database upon value change

Just add JS below to the mapping from toggle component to the request parameter:
prereturn (value === "on");/pre

https://devcenter.appery.io/documenta...

Return to “Issues”