The CreatorCon Call for Content is officially open! Get started here.

Modal Buttons

alexcolbert
Kilo Guru

Hello,

 

I've created a modal with some custom buttons. I want 2 of the buttons to redirect to other portal pages when clicked on.

 

Modal currently looks like the below:

 

buttons: [{
					label: i18n.getMessage("Back to Item"),
					cancel: true
				}, {
					label: i18n.getMessage("Select More Items"),
					
				}, {
					label: i18n.getMessage("View Cart and Checkout"),
					primary: true
				}]
			}).then(function(){
				var url = "/sp?id=sc_cart";
				top.window.open(url, '_blank');
			}, function(){
				var catalog = "/sp?id=sc_home";
				top.window.open(catalog, '_blank');
			});

 

Clicking 'View Cart and Checkout' works fine and directs to the cart page.

I'd like 'Select More Items' to redirect to 'sc_home'.  I added the extra function at the bottom but this causes 'Back to Item' to redirect to 'sc_home'.

 

Can anyone let me know what I'm missing?

 

Thanks!

1 REPLY 1

Markus Kraus
Kilo Sage

Remove the 'cancel: true', then it will work like this (the button is actually the argument of the first function):

spModal.open({
  buttons: [{
    url: "/sp?id=sc_home",
    label: i18n.getMessage("Back to Item")
  }, {
    url: "/sp?id=sc_home",
    label: i18n.getMessage("Select More Items"),
  }, {
    url: "/sp?id=sc_cart",
    label: i18n.getMessage("View Cart and Checkout"),
    primary: true
  }]
}).then(function(btn){
  top.window.open(btn.url, '_blank');
});

 

Please let us know if this answered your question.