passing values from client side to server side

Post any questions you have about using the Verj.io Studio, including client and server-side programming with Javascript or FPL, and integration with databases, web services etc.

Moderators: Jon, Steve, Ian, Dave

azaleas
Ebase User
Posts: 81
Joined: Thu Jul 30, 2015 12:44 pm

passing values from client side to server side

#1

Postby azaleas » Tue Feb 09, 2016 11:43 am

I'm transferring a value to a field via client side javascript. However, I'm also using server side insertRow(), deleteRow() functions. And, whenever I add a row or delete row, my field value, which got the value from client side returns to initial value, which is empty.

How can I overcome this issue? Do I have to avoid using server side buttons of Ebase?
0 x

azaleas
Ebase User
Posts: 81
Joined: Thu Jul 30, 2015 12:44 pm

#2

Postby azaleas » Tue Feb 09, 2016 12:36 pm

I've been reading the forum to find some answers. I had AJAX ticked, so I removed it and tested again and saw that page gets refreshed whenever I click a button added from the Palette. So, given that the page gets refreshed all my client side scripts start over, meaning my data gets lost.

How can I prevent page reloads on button click events fired via server side script? Or better yet pass the value to server side before the reload?
0 x

Jon
Moderator
Moderator
Posts: 1342
Joined: Wed Sep 12, 2007 12:49 pm

#3

Postby Jon » Wed Feb 10, 2016 9:44 am

Can you provide some more details of your field and exactly how and when it is populated i.e. which client-side event. I don't think I quite understand your scenario, but here are some suggestions:

1. You need to use Ajax otherwise page refreshes will replace the browser page. If the field in question is an Ebase field then it will be submitted to the server on the (non Ajax) button click and you won't have this problem. If the field is outside of Ebase control, then it will be lost.

2. With Ajax enabled, you might find that moving the Javascript client api call solves the problem. It sounds like your field is being refreshed by the server on each Ajax button click. Try moving the client api call to the ready event of the container control - i.e. the control containing your field.
0 x

azaleas
Ebase User
Posts: 81
Joined: Thu Jul 30, 2015 12:44 pm

#4

Postby azaleas » Thu Feb 11, 2016 12:26 pm

Hi Jon,

I managed to pass my value to server side by using ready event of the container control. I'm using the setFieldValue with autorefresh true. However, now my other values on ebase fields get lost. I think the reason is that when setting refresh to true, all my not validated data gets erased.

I guess the quick solution here would be an immediate validation. But, I don't want to put that on each and every field.

Another idea is to call a server side function from client side which will validate all the fields before autorefresh.

Any other ideas?
0 x

azaleas
Ebase User
Posts: 81
Joined: Thu Jul 30, 2015 12:44 pm

#5

Postby azaleas » Thu Feb 11, 2016 1:19 pm

How can I validate the fields via script?
0 x

azaleas
Ebase User
Posts: 81
Joined: Thu Jul 30, 2015 12:44 pm

#6

Postby azaleas » Thu Feb 11, 2016 1:33 pm

I have another idea: Use input with type button, rather than submit(which is Default for Ebase) then call server side function from client side.
0 x

Jon
Moderator
Moderator
Posts: 1342
Joined: Wed Sep 12, 2007 12:49 pm

#7

Postby Jon » Thu Feb 11, 2016 2:07 pm

I'm still not clear on what you're trying to do and how you've implemented it. Why not just set autorefresh to false? That would be the usual thing to do if you just want to set a field value on the server.
0 x

azaleas
Ebase User
Posts: 81
Joined: Thu Jul 30, 2015 12:44 pm

#8

Postby azaleas » Thu Feb 11, 2016 4:31 pm

Here's the scenario:

AJAX is on.

I'm running Cropit jQuery Plugin to upload images.

I have a profile page with 3 panels.

Panel 1: User details with all the fields mapped to User Database resource.

Panel 2: Profile picture where I run the Cropit function.

Panel 3: Additional details with fields mapped to corresponding DB resource. This one is a table.

Two buttons: Save button(Saves everything) and Add additional details button.(Adds a row)

At first I had this issue:

Whenever I clicked any Ebase button my Cropit image got reloaded and shown as empty, because the input file was null. In order to solve this I added a server side function to send cropped image to an ebase field.

Then, I had the following issue:

Depending on setting the autorefresh to true or false (in setfieldvalue function):

If set to true all my unvalidated fields got nulled and I was seeing empty fields on my browser.

If set to false, I could see the field values but just on client side. On server side they were null. But before, the insert query was sent with all the fields. So, here, I just used fetch to fetch the last entered data and then uploaded the image the way I wanted.

I know it sounds little complicated. I'm just trying to re create a profile page I created using php on wordpress.

And its almost done. Now, I send the cropped image to server side field on every button click but originally it should be only on submit (crop and save).
0 x


Who is online

Users browsing this forum: No registered users and 9 guests