sweetalert2 confirm delete when render returning a link in Datatables - datatables

I am using Datatable and doing my Remove by rendering returning a link. I wanted to do my Remove by confirm with SweetAlert2 however, it was not able to work as expected.
How do I use sweetalert, I cannot assign an id for returning render a link

I am not sure where you are getting stuck.
Here is my version:
I am using SweetAlert 2:
<script src="https://cdn.jsdelivr.net/npm/sweetalert2#10.15.7/dist/sweetalert2.all.min.js"></script>
I have the following render function in my DataTable:
{
render: function (data) {
return '<a id="del" href="/your/example/here/' + data + '">Remove</a>';
}
}
This is a simplified version of your code, just as a demonstration.
I have the following click handler:
$('#del').on('click', function( event ) {
event.preventDefault(); // don't forget to prevent the default event
Swal.fire({
title: 'Are you sure?',
text: "You won't be able to revert this!",
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Yes, delete it!'
}).then((result) => {
if (result.isConfirmed) {
Swal.fire(
'Deleted!',
'Your file has been deleted.',
'success'
)
}
});
});
This generates a table with links.
When I click on any link, I get the following pop-up alert:
I have not handled anything relating to actually using the link to delete a resource. I leave that up to you, as a follow-on task, after you get the alert working.
You did not really explain what the specific problem is that you are facing, except to say "it's not working".
If you have new, additional, problems after this then you can open a new question - but please try to provide sufficient details, including error messages from your browser's console and an easy-to-recreate problem description with related code.

Related

Integrating nativescript-paytm plugin in nativescript-vue application

I'm having a nativescript-vue application where I want to integrate nativescript-paytm plugin, I created a method on click event: payNow() which contains all the necessary details of Paytm as described in Readme.md/documentation/demo app.
import {
Paytm,
Order,
TransactionCallback,
IOSCallback
} from "#nstudio/nativescript-paytm";
const paytm = new Paytm()
methods: {
payNow() {
paytm.setIOSCallbacks({
didFinishedResponse: function(response) {
console.log(response);
},
didCancelTransaction: function() {
console.log("User cancelled transaction");
},
errorMissingParameterError: function(error) {
console.log(error);
}
});
// Sample order
const order = {
// This will fail saying duplicate order id
// generate your own order to test this.
MID: "rzqfRq*******83",
ORDER_ID: "NOETIC_ORDER_0001",
CUST_ID: "CUST_6483",
INDUSTRY_TYPE_ID: "Retail",
CHANNEL_ID: "WAP",
TXN_AMOUNT: "10.00",
WEBSITE: "WEBSTAGING",
CALLBACK_URL: "https://pguat.paytm.com/paytmchecksum/paytmCallback.jsp",
EMAIL: "rubal#example.com",
MOBILE_NO: "9876543210",
CHECKSUMHASH: "NDspZhvSHbq44K3A9Y4daf9En3l2Ndu9fmOdLG+bIwugQ6682Q3JiNprqmhiWAgGUnNcxta3LT2Vtk3EPwDww8o87A8tyn7/jAS2UAS9m+c="
};
paytm.initialize("STAGING");
paytm.createOrder(order);
paytm.startPaymentTransaction({
someUIErrorOccurred: function(inErrorMessage) {
console.log(inErrorMessage);
},
onTransactionResponse: function(inResponse) {
console.log(inResponse);
},
networkNotAvailable: function() {
console.log("Network not available");
},
clientAuthenticationFailed: function(inErrorMessage) {
console.log(inErrorMessage);
},
onErrorLoadingWebPage: function(
iniErrorCode,
inErrorMessage,
inFailingUrl
) {
console.log(iniErrorCode, inErrorMessage, inFailingUrl);
},
onBackPressedCancelTransaction: function() {
console.log("User cancelled transaction by pressing back button");
},
onTransactionCancel: function(inErrorMessage, inResponse) {
console.log(inErrorMessage, inResponse);
}
});
}
}
While executing so I only get to see screens like this:
I can see that while cancelling I get a message in my console User cancelled transaction by pressing back button that means these things are also working but I am unable to see any screen, atleast if any error message is visible I can try to debug. Help me out with this.
Here's the message which I get in my command prompt:
JS: Avoid using ListView or ScrollView with no explicit height set inside StackLayout. Doing so might results in poor user interface performance and a poor user experience.
chromium: [INFO:library_loader_hooks.cc(36)] Chromium logging enabled: level = 0, default verbosity = 0
chromium: [INFO:aw_field_trial_creator.cc(54)] First-WebView-Experiment not found
JS: 'User cancelled transaction by pressing back button'
JS: Avoid using ListView or ScrollView with no explicit height set inside StackLayout. Doing so might results in poor user interface performance and a poor user experience.
chromium: [INFO:CONSOLE(0)] "The SSL certificate used to load resources from https://pguat.paytm.com will be distrusted in the future. Once distrusted, users will be prevented from loading these resources. See https://g.co/chrome/symantecpkicerts for more information.", source: (0)
chromium: [INFO:CONSOLE(0)] "The SSL certificate used to load resources from https://pguat.paytm.com will be distrusted in the future. Once distrusted, users will be prevented from loading these resources. See https://g.co/chrome/symantecpkicerts for more information.", source: https://pguat.paytm.com/oltp-web/processTransaction?ORDER_ID=NOETIC_ORDER_0001 (0)
JS: 'User cancelled transaction by pressing back button'
JS: Avoid using ListView or ScrollView with no explicit height set inside StackLayout. Doing so might results in poor user interface performance and a poor user experience.
chromium: [INFO:CONSOLE(0)] "The SSL certificate used to load resources from https://pguat.paytm.com will be distrusted in the future. Once distrusted, users will be prevented from loading these resources. See https://g.co/chrome/symantecpkicerts for more information.", source: (0)
chromium: [INFO:CONSOLE(0)] "The SSL certificate used to load resources from https://pguat.paytm.com will be distrusted in the future. Once distrusted, users will be prevented from loading these resources. See https://g.co/chrome/symantecpkicerts for more information.", source: https://pguat.paytm.com/oltp-web/processTransaction?ORDER_ID=NOETIC_ORDER_0001 (0)
For more info I raised issue on GitHub repo: https://github.com/nstudio/nativescript-paytm/issues/5
Edit:
I tried adding it through playground, but since it uses external library integration is not possible. However I tried using in following link
https://play.nativescript.org/?template=play-vue&id=CpqoNA&v=2
Hope this gives more clear picture about it.
Edit:
My whole payment.vue file looks like following link: https://gist.github.com/nitish1986/f23644514082efe757f132e943f2df51
Thanks

Can anyone help implementing Nuxt.js Google Tag Manager?

Hey i've built a Nuxt app and am having trouble with the package #nuxtjs/google-tag-manager package. Found below. The documentation is pretty light and I haven't found many example implementations out there. In my nuxt.config.js I have the following set.
['#nuxtjs/google-tag-manager', {
id: process.env.GTM_ID,
layer: 'dataLayer',
pageTracking: true
}],
..but unfortunately am not getting any Page Views in Google Tag Manager
Does anyone have any ideas or experience in how to best implement GTM or what has worked for them?
Thanks in advance
I had a look at the package, inside https://github.com/nuxt-community/gtm-module/blob/master/lib/defaults.js there is this piece of code:
function startPageTracking(ctx) {
ctx.app.router.afterEach((to) => {
setTimeout(() => {
ctx.$gtm.push(to.gtm || {
routeName: to.name,
pageType: 'PageView',
pageUrl: '<%= options.routerBase %>' + to.fullPath,
pageTitle: (typeof document !== 'undefined' && document.title) || '',
event: '<%= options.pageViewEventName %>'
})
}, 250)
})
}
From that, it looks like the datalayer looks like this:
{
routeName: to.name,
pageType: 'PageView',
pageUrl: '<%= options.routerBase %>' + to.fullPath,
pageTitle: (typeof document !== 'undefined' && document.title) || '',
event: '<%= options.pageViewEventName %>' //default is 'nuxtRoute'
}
The default name for the event is 'nuxtRoute'. Thus in GTM, you'll get to define a custom event trigger to trigger on the "nuxtRoute' event. Like so:
Then you want to create two DataLayer variables in GTM that will capture pageUrl(Please note the camel case) and possibly routeName, I say routeName is optional depends on if you're changing/updating the of the document or not.
Then create your Google Analytics tag in GTM. Make sure it is the "pageview" type, then check the "enable overriding settings in this tag" checkbox, under "more settings > fields to set" type in "page" for fieldname and for "value" reference that variable we created. If you want to set the page title using the to.name variable just use the "title" field. Make sure you add the nuxt route trigger as well under "triggering".
Save and publish everything or run it in preview mode and you should see the pageviews some through.

Liferay Login Hook, error pop up

I need to show the errors in login hook of liferay in popup, but the sentence is only a line of code, so I don't know how implement the popup.
the key line is the next:
<liferay-ui:error exception="<%= NoSuchUserException.class %>" message="This message is editable" />
This error is to showed in a label but I didn't need this.
like this example::
http://www.jose-aguilar.com/blog/wp-content/uploads/2012/07/bootstrap-modal.png
In case you need to show errors in dialog box,I suppose you are using
SessionErrors.add(actionRequest, "error");
to send error from action phase.You can check SeesionErrors for 'error' attribute and display your message in dialog box:
<% if(!SessionErrors.isEmpty(renderRequest))
{
String error=LanguageUtil.get(pageContext, "error");
%>
<aui:script>
YUI().ready(function(A) {
YUI().use('aui-base','liferay-util-window', function(A) {
Liferay.Util.Window.getWindow({
title : 'Error',
dialog: {
bodyContent: '<%=error%>',
destroyOnHide: true,
cache: false,
modal: true,
height: 300,
width: 300
}
})
});
});
</aui:script>
<%} %>
Have look at the Alloy Documentation
http://alloyui.com/examples/tooltip/
As Shivam suggested, you can use a scriplet to get the message.

FB.ui with method 'feed' is resulting in an 'unknown error' and CAPTCHA request

We're using code that we've used before, so I suspect that this may be site-related. In using a standard:
FB.ui(
{
method: 'feed',
app_id: '<?= $LDP->config->facebook->id ?>',
name: 'Post Name',
link: flink,
picture: "https://www.domain.ca/templates/visual/images/share.gif",
caption: "Caption",
description: 'Join the fun today!',
actions: [
{ name: "Check it out!", link: flink }
]
},
function(response) {
if (response && response.post_id) {
alert('Post was published.');
} else {
alert('Post was not published.');
}
}
);
It first displays the expected share dialog, and when you click the button at bottom right to go through with the stream publication, a new popup appears with:
Title: Require Captcha
unknown error
Security Check
please enter the text below
[captcha appears]
The only button is "Ok". Correctly solving the Captcha results in a crash (Facebook servers throwing a 500 error).
Any ideas?
I'm experiencing this too. I can confirm that changing the domain in the link makes it all good.
I got a parallel domain for our app and after three days the same Captcha with "Unknown error" appeared. Best of all – if a user gives the correct Captcha words the post will still fail. This is pretty annoying and we're getting complaints from our users.
Turns out this is a bug with Facebook (broken captcha issue). The pop-up is an innate anti-spam system, but people should be able to succeed with the CAPTCHA. I'd filed a private bug with Facebook, and it's slated to be fixed apparently.
Try calling FB.init() before calling FB.ui() to see if that helps get things in sync. Also be sure to specify the channelUrl in the init call too.

Loading indicator with dojo XHR requests

I only recently started using dojo and I am doing numerous ajax calls using dojo xhrGet, xhrPost,..etc. Now I have an animated gif image which i want to use to indicate "loading" to the user. I am not too sure how this can be done. Can someone please advise me on this? here is my code,
dojo.xhrGet({
url: registcarturl,
handleAs: "json",
preventCache: true,
load: function(data, ioArgs) {
//DO STUFF WITH data HERE
},
error: function(error) {
alert("sorry ! an error occurred while adding to the cart with ajax");
}
});
How do i get my loading gif file into the interaction? Thank you.
Have a look at dojox.widget.Standby: http://dojotoolkit.org/reference-guide/dojox/widget/Standby.html
To give you an example, define the widget.Standby
<div jsId="basicStandby1" dojoType="dojox.widget.Standby" target="yourDomTarget">
After calling dojo.xhrGet, show it:
basicStandby1.show();
And when you receive your answer, hide it:
basicStandby1.hide();