WFFM MVC add javascript onclick when Submit - model-view-controller

I'm currently trying to trigger dataLayer push events on submit for wffm mvc form. There are a couple of sources I've found and none of them has worked so far for MVC. The closest to what I could work with is combining what I've gathered with these two links Sitecore WFFM: act on success and Trigger Google Analytics Events on Sitecore Web Forms
Currently, I'm stuck on trying to output the form's success message since wffm mvc does not have Form.SuccessMessage(or as far as I know).
For webforms it's like this:args.Result = args.Form.SuccessMessage + script;
Any help would be much appreciated.

datalayer where trigger on html element push using javascript. for example:
Your html element on show ,you want to push datalayer.
$('#loading').on('shown.bs.modal', function () {
dataLayer.push({ event: 'modalShowSuccessGoogleTy' });
});
ı hope this example can be helped you.

Related

Integrating Surveyjs with Nativescript + Angular

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

Custom button in Edit form that displays result

I am fairly new to .NET and MVC3 - and even Ajax and Json, and am working on an MVC3 (razor) application, using jqGrid, and so far it is immense(jqgrid that is!) and has dealt with everything I have thrown at it.
However, I have One Outstanding peice of functionality that I do not know How to accomplish.
Within the Edit form of a Row, I have Placed a Custom button called 'Reset Password'. I need the Onclick Event to call a piece of functionality in my Controller to go through some logic, generate a Password, and Return the new Password to the Screen.
Can anyone tell me How can I achieve this?
May thanks in Advance.
You can return a partial view result or json data from the action.
See the partial view approach here

Using ajax inside the Web Content Display Portlet

I am using the liferay community edition 6.0. One of the pages will be using only the Web Content Display portlet to add content to it. I want to achieve the following inside that content i will load some html links that will be used to download some pdf. I want to add an ajax call to me domain before the actual redirect to the link has been done.
My question is the following. I've used the hook feature of liferay to add a java script ajax function in to the view.jsp. The click event is caught in the view.jsp but since there is no controller i don't know how to propagate this event to the domain.
So far i've done this function on my custom create portlet that are done using Spring MVC. But for this specific portlet i cant seem to find the controller or what ever handler the Web Content Display is using(if any).
Can someone please tell me if this is possible and point me in some direction if it is possible.
I am not sure what functionality you're trying to implement here, but I'll try to help. You can make an Ajax call to another jsp in your hook from your view.jsp.
jQuery.ajax({
type: "POST",
url: "/jsp/path/your.jsp",
data: "country="+country,
success: function() {
...
}
...
});

Return Pop Up As a response In MVC ASP.NET

In facebook after I shared something in my wall I get a nice pop message about my activity. Sometimes whenever there is an error with they gave a nice pop about the error. Like this.
I know in facebook everything is about ajax.
I am creating a web application using mvc 3 asp.net. In my web app there is something similar to sharing links like in facebook.
I implemented this feature using ajax and partial views and it is works fine.
When user submit a new link, In my controller action method I update the db and return a partial view finally update my view with nice animation.
Now my problem is how can I give a pop up response while updating my view(facebook wall).
I want to do both of them with the ActionResult.
I not sure this is the correct way to do this.
Briefly what I want is update my view with automatic pop up response. Hope you understand what I want.
Let me know If you need any clarification on this.
Please help me to implement this function.
Thanks !!
Well a "popup" is client-side functionality, not server-side. You can't do it with actionresult per-se.
Perhaps you should return a PartialViewResult from an action method, which is fired by an AJAX call (e.g jQuery).
Then in the callback, set the HTML of a hidden container/div to the partial view's HTML, then show it in a fancy way.
Something like jQModal or jQuery UI dialog is perfect for this.
I found the answer myself. Add Jquery library and unrobustive javascript and
return JavaScript("alert('Some message')");

Live Search using ASP.NET MVC and AJAX

I am looking to implement a live search in my MVC app similar to this site when you type in a question and results come up that are similar or like the search on http://www.krop.com/
I have the search code all working and results updated. I just need to know how to add the AJAX to the MVC framework (I know this site was built using it) so that when I type the results are updated.
I had this all working in normal ASP.NET Forms app.
what you need to do it attach to Jquery onchage event handler, and then call some ajax method of jquery ($.load , $.ajax etc...) and the information from a specified controller. asp.net mvc controller can return json results so you can later manipulate it in your javascript code.
if you have any other questions go ahead and ask.
An ASP.NET MVC site will have AJAX and JQuery available by default.
Mike Bosch's Blog can give you some pointers on this

Resources