I am trying to merge surveyjs along with my NativeScript application. I have referred URL for merging the same with Angular application
From the Angular demo code given on website, we have to add event handler for Complete button where we can get the response from surveyjs. Is it possible to integrate similarly for Nativescript Mobile application? Here is the approach which i feel can be taken.
Display
Create a HTML as provided by SurveyJS with required CSS and JS
referenced and add them as a file in project.
Modify HTML once i get the survey question json back from server.
Show the HTML as part of WebView. This will take care of displaying
the survey on my Application.
Here are my challenges during Submission
As per the process given on SurveyJS, i need to add handler for
oncomplete which will get the result json for me. How can i add
handlers for Complete button click in my code? Also please note that
there is a possibility that there may be multiple surveys on a single
page.
Apart from Survey, there are other fields also on the page and user
will submit them all in one go by clicking submit button of the page.
Hence i am planning to hide Complete button provided by SurveyJS
page. This needs to be triggered via code. Can this be done?
If someone can give directions on whether this scenario can be handled in nativescript application with Angular,it would help immensely.
yes it can be done using nativescript-webview-interface plugin.
add jS code inside WebView to handle oncomplete event from surveyJS. and on that function call emit some event to native app. after that add nativescript code to listen for that event and get the JSON back.
inside webView JS function
var oWebViewInterface = window.nsWebViewInterface;
// emit event to native app
oWebViewInterface.emit('anyEvent', jsonData);
inside native App
oWebViewInterface.on('anyEvent', function(jsonData){
// perform action on event
});
for more details on this you can check plugin readme file https://github.com/shripalsoni04/nativescript-webview-interface
Related
hi i wanna have a filter pre every web pages that check someting and if that thing was incorrect show me an error page
and if it was fine just show me the page
Vaadin is mostly based on individual interactions such as clicking buttons or scrolling in a grid, rather than viewing pages. What you can still do is to use UI::addBeforeEnterListener to get an event before navigating to a new target. You can use a VaadinServiceInitListener to register that listener for all your UI instances.
For more information, have a look at this blog post that I've written on the topic.
I've got a component that downloads data from an API. When the user clicks Search, the content from the API is fetched via AJAX. This content from the API is in JSON and has got an ID of the product inside. I am able to create new HTML elements based on this content and put them inside my site, but I would like every created on the fly element to have routerLink="/detailsPage/itemID" working, so that after clicking it would route to detailsPage with apropriate ID. How to do it in the most simple way? I assume some recompiling of refreshing is needed.
The answer to this question is HTTPClient - Angular offers it as an easier way to use XMLHttpRequest (AJAX) in Angular applications, and using it also makes sure that routerLink or any other Angular directives will work on objects created dynamically with this method.
Angular - HTTPClient
I would like to open a Dialog or Modal if I get a status 401 in AUTH_ERROR. What is the best way to implement this.
Thanks!
You'll have to take the custom app route:
Follow the documentation to bootstrap your custom app.
Add a saga which should take the latest (takeLatest in redux-saga) FETCH_ERROR action. This action has an error property. The saga should then dispatch (put in redux-saga) a custom action which will be used by a reducer you'll add.
This reducer should contain the data required for the modal: at least a boolean determining whether to show it or not.
Finally, update your custom app by adding it a custom redux connected component which will check if it has to show your modal.
I just wonder how to do some events with Javascript Apache Cordova project on Visual Studio
Do i need to create new js file for each html file (like Controller - View on MVC)
What is the events fire sort ? (Which event first, which event next firing )
I do same sample, i put one button and when i click button i open new page, when i fire backbutton, first page comes, but button on the first page not working anymore, what is wrong ?
And at last, how can store some data on SQLite database localy and do some read,write,list actions ? Is there any sample code with these ?
Thanks everybody,
Do i need to create new js file for each html file (like Controller - View on MVC).
It's not necessary, you can put all code to one .js file. Depends on your coding style and used framework.
What is the events fire sort ? (Which event first, which event next firing ).
Cordova app, in fact, is a web page in mobile browser. So you should read proper docs. For special Cordova events see this page: http://cordova.apache.org/docs/en/4.0.0/cordova_events_events.md.html#Events
I do same sample, i put one button .....
First af all, it's recommended to use Single-Page-Application, for details see there: http://cordova.apache.org/docs/en/4.0.0/guide_next_index.md.html#Best%20Practices. As for your app, you shoukd provide some more details. Looks, like you missed some script or link while reloading first page.
how can store some data on SQLite database localy
First, read this page about storage: http://cordova.apache.org/docs/en/4.0.0/cordova_storage_storage.md.html#Storage. It's recommended to use WebSQL, but you can try this plugin: https://github.com/brodysoft/Cordova-SQLitePlugin, or read this article about WebSQL: http://msopentech.com/blog/2014/05/05/websql-plugin-for-apache-cordova/
I want to upload a file using the < s:file > tag, but Struts2 doesn't support Ajax for this functionality, as far as I know. I tried to do it using the Struts2 jquery plugin but it overwrites some jquery functions that i need an can't change right now (like .dialog()).
Is there an alternative way to do it?
There are many jquery based plugins for this purpose.
I am using this library. Its the most simple and elegant plugin, minimal requirements and lots of options.
Here are some other plugins which I considered(my preference was a plugin which doesnt use flash)
This one shows thumbnail before uploading and also overall progress
This one shows remaining time, uploading speed and remaining size
This is how I do it (I'm not using JQuery):
I hide an iframe inside my page. I give it an id (iframe for example) and a name (the same than the id).
I set the attribute "target" on my form to the id of the hidden iframe (then, the response from the server is loaded inside the iframe.
I register an event handler on the iframe to react on the onload event. The handler analyse the response from the server. Alternatively, I sometime just return javascript code from the server in a <script> tag. This code performs action on the client upon success or failure of the intended action.
If you like the idea, you may want to read this article or this one: