I'm trying to make a simple Sencha Touch App that submits a form with attached images, and stores the data in a remote MySQL database via PHP.
The user-inserted images are stored in a data store.
When the user clicks the submit button, I would like all the data in the store to be encoded into a JSON string which I can easily send to my database.
Is there any way to do this in Sencha Touch?
Thanks!
Sencha Touch has the JSON lib included, you can encode in the following manner:
Ext.util.JSON.encode(formDataArray)
Also have a look at the Sencha Touch API Docs here: http://docs.sencha.com/touch/1-1/#!/api/Ext.util.JSON which references http://www.json.org/js.html
You can encode image to Base64 string and when attached to your form you can store base64 string value in a hidden field in your form.
When user clicks submit button you retrieve values in your form using activePanel.getValues(false).This gives you JSON presentation of components you used in your form and their values.
Related
i have created a form to make a submission to an api using axios.
There are 3 other parameters and then the files to submit.
I got it working with one file but what I need to do is be able to have multiple files uploaded and then submit, i tried using the multiple flag but this seems to only allow you to select multiple files in the same folder at once rather than choosing and selecting the files individually.
I don’t want the files sent to the api until the submit button is clicked though.
I thought maybe about using local storage to put the files and then pull to submit at once when the button is clicked?
You can use Base64 encode in client side and add the encoded string to your post request and decode from server side.
I am trying to make an input field which accepts text and image with copy/paste feature. I am looking for a way to save the contains of this field and then retrieve and display the same in non-editable field.
Can this be done with dijit.editor?
I appreciate any tip on this. Thank you.
You will need more than just digit.Editor.
You will need at least something like:
digit/Editor for the writable UI
div for the readonly UI
dojo/request for sending Editor value to backend and for getting saved value from the DB
A server able to handle non static pages (like Apache + php)
A database (like mysql)
A backend API to save and read from the database
I'm building a Mac OS native application that uses a WebView to display custom data forms. The user will be able to fill out these forms to input data to the application. I need to be able to capture whatever data gets submitted as part of these html forms.
So if for example a webform comes up that has a text field which the user can use to enter a name - along with an 'OK' button next to it which submits the data - I would need to be able to capture whatever the user entered in that text field.
Keep in mind the HTML is loaded locally, not from a URL. Like so:
[[webview mainFrame] loadHTMLString:htmlSource baseURL:nil];
How can I capture any data that is being send entered this way?
This can easily be done in javascript, by intercepting the submit of your form and tracking the data. For this answer, I assume your webpage uses jQuery:
[webView stringByEvaluatingJavaScriptFromString:#" \
$('#yourForm').on('submit', function(e){ \
console.log(JSON.stringify($(this).serializeArray()));\
});"];
If you need this information in the Objective-C code, this thread describes how to bridge calls between javascript and Obj-C
I have an application that has 3 level of data depth:
list of presentations
presentation detail
presentation slides
Right now when user came to the app he's presented with list loaded from JSONP store. He click on one item and the callback function receives the record. It pushes it into new view - the detail and displays it. User can disclose presentation slides from there - data record is passed from detail again.
Problem is when user refreshes the page or came from URL. If he came to url like /presentations/slides/1, he wants to see the slides for presentation id:1. Problem is that as long as he wasn't at the list, data was not loaded and because it was not loaded, it was not passed to the detail and the detail didn't pass it along to the slides view. So I have no data.
But I still have the ID! Comming from the PHP's Zend Framework, I would call something like: this.store.find(1), but I can't find any way to do this.
How do I load something from the store based on it's record.data.id?
To add more, store.load() seems to work asyncronously, so when I do:
store.load();
store.each(function(rec){console.log(rec);});
It wouldn't work with JSONP store, because the data is not loaded yet. But when I use Chrome Debuger and pause the execution to let the data load, it works :(
You are correct the load is asyncronously so all you have to do is use the callback function of the store. You can find an example here How to get data from extjs 4 store
How can I post a FormPanel as well as an EditorGrid ( Grid Panel) as a single JSON object in ExtJS with Rails 3.0.3?
For Ex: I have a FormPanel and a GridPanel, when it's submitted, it goes as a single JSON Store into the controller.
P.S: Any way to do that without using Arrays?
Thanks in advance !
you might want to split the submit event into two elements.
In other words, you can encapsulate the form and the grid on 2 separate elements you can check for all fields during the submit. That would create 2 separate post events.
However, why would you want to do that. you should just redirect the events of each individually as an action happens.
And no, extjs formats everything in a JSON that you would have to decode out to break the array.