For a client requirement in opportunity I have added a button to go to a visual force page. Before showing the next page though client wants to show a popup on that button click to confirm the operation. If not confirmed it should go to a different page. I am very new to salesforce. Please help.
In case you are using the Lightning version of Salesforce, you can follow the following steps:
Create an Aura Component as follows:
.cmp file
<aura:component implements="force:lightningQuickActionWithoutHeader">
Are you sure you want to proceed?
<div class="slds-align_absolute-center">
<lightning:button
label="No"
variant="destructive"
onclick="{!handleNo}"
></lightning:button>
<lightning:button label="Yes" onclick="{!c.handleYes}"></lightning:button>
</div>
</aura:component>
controller.js (replace MyOtherVisualforce and MyVisualforce with your Visualforce names)
({
handleNo: function (component, event, helper) {
var urlEvent = $A.get("e.force:navigateToURL");
urlEvent.setParams({
url: "/apex/MyOtherVisualforce",
isredirect: "true"
});
urlEvent.fire();
},
handleYes: function (component, event, helper) {
var urlEvent = $A.get("e.force:navigateToURL");
urlEvent.setParams({
url: "/apex/MyVisualforce",
isredirect: "true"
});
urlEvent.fire();
}
});
Create a new Action for the Opportunity object (go to the Buttons, Links and Actions section of the Opportunity setup and create new Action) and as Action Type select Lightning Component and as Lightning Component select the one that you just created
Add the Action to your Opportunity layout
By doing this, the action will open your Aura Component which will present the two options that you need. After clicking one of the options, the e.force:navigateToURL will perform the redirection.
Related
I'm using Landing page so I already have button I want to redirect people after clicking on this button the button id is: button-c86b272c I want to redirect people after clicking on this button not create new button .
I have this code to redirect after time out :
<meta http-equiv="refresh" content="10; URL=www.google.com/" />
but I want one to redirect after click on exicting button not new button I tried change the first code to this :
<meta http-equiv="refresh" onclick="button-c86b272c; URL=www.google.com/" />
but it did not work something isn't right
Hope You help me
The meta tag is not a visible DOM element, it means it does not have a "body", thus cannot be clicked on. meta tag is used to describe metadata about your page, or set HTTP headers.
To redirect to a specific URL after the button is clicked you can use JavaScript:
// First we need to create a handle to the DOM element
const buttonElement = document.getElementById("button-c86b272c");
// Then we add an event listener, which will execute a passed function after the event (in our case "click") is fired
buttonElement.addEventListener("click", () => {
// We set the destination URL, the page reloads automatically
window.locaton = "www.google.com/";
});
Add this code to your page or put it in a separate file and make sure to import it or you can add the event listener directly in your HTML using the onclick property, like this:
<button id="button-c86b272c" onclick="window.location = 'www.google.com/'"></button>
However this approach is not recommended and it's best to put your JavaScript in a separate file and not mix it into the HTML.
Hope this helps!
I have created the button in the gmail inbox using inboxsdk.
Now i want to get a pop up by clicking on that button
2.Pop up should contain a link which navigates to my website page(xyz.com/login.php)
How can i do these using inboxsdk
Screenshot:
If you are still struggling with this, I would suggest a simple solution which is to fire a JavaScript confirm dialog see here. On confirmation you could redirect the user, using window.location.href = '<your-url>';.
Another solution would be to use InboxSDK's widgets.
Example:
InboxSDK.load(2, '<InboxSDK-app-id>').then((sdk) => {
...
const el = document.createElement('div');
el.innerHTML = 'Link description';
sdk.Widget.showModalView({
title: 'Modal Title',
el
});
});
For more ModalOptions look here.
Notice: I set the attribute target attribute of <a> tag to "_blank". This makes sure the url opens in another browser tab.
A third, more direct (optional) solution would be to add an onClick event listener to which you attach a function that redirects the user to your url, see a code example here.
A fourth and better possible solution would be to add a DropdownView to your button's onClick function, see example code here.
setup : function(ed) {
ed.on("click", function(e) {});
};
Tried setting up like this.But this get triggered when I click inside the editor text-area. So How do I capture the click event when a user clicks on "New document" from "File".Using Tinymce v4
TinyMCE does not issue any specific event when New Document is selected from the Menu. You can do one of two things:
1 - Leverage the ExecCommand event and look to see what actual command was issued.
When you select File -> New Document the editor fires an ExecCommand event and the command property is set to the value mceNewDocument. You can add code to your TinyMCE configuration that looks for any ExecCommand event and then checks to see if the command property is set to mceNewDocument. For example you can put this in your TinyMCE configuration...
setup: function (editor) {
editor.on('ExecCommand', function (e) {
if("mceNewDocument" == e.command) {
console.log('New Document was run...");
}
});
}
2 - Build a custom New Document menu option.
You can create a custom menu option and stop using the default one. Then you can add your own custom logic to do whatever you need when this option is selected. You can learn more about custom menu items here:
https://www.tinymce.com/docs/demo/custom-toolbar-menu-item/
The default menu option is defined in the FormatControls.js file within TinyMCE so you can use that as a template for your own custom button.
I have one search form with search button and some field, when I put value in form field and click on search button then come back on form by clicking on link(modify search form) then form value does not reset...Please check it here(http://dev.viawebgroup.com/search/)
Thanks
Try this:
<script>
function test(){
var input = document.getElementById('search');
input.value = '';
};
</script>
Add onload to the body:
<button onclick="test()">Clear</button>
Add id to input field:
<input type="text" id="search">
Fatal flaw rests form befor data is sent
The simplest way I found is
onsubmit="this.reset()"
Just put this in the form tag and all's well, simple yet efective.
I someone wanted a button excluesivly for form reset I would use onclick and write the reset in a function like this.
function clform()
{
documentgetElementById('myform').reset();
}
The first is tried and true, the second I just wrote but should work.
The function works well used in a onbeforeunload event in the body.
I have been working on this problem my self because the page I wrote is dynamically updated and was keeping form data when back button of browser was used. I also used PHP to reload the page after submission and onfocus to reload the page when form is selected so input is on a fresh page and not the dynamically updated page.
As we are facing GWT performance issues in a mobile app I peeked into Google Wave code since it is developed with GWT.
I thought that all the buttons there are widgets but if you look into generated HTML with firebug you see no onclick attribute set on clickable divs. I wonder how they achieve it having an element that issues click or mousedown events and seemingly neither being a widget nor injected with onclick attribute.
Being able to create such components would surely take me one step further to optimizing performance.
Thanks.
ps: wasnt google going to open source client code too. Have not been able to find it.
You don't have to put an onclick attribute on the HTML to make it have an onclick handler. This is a very simple example:
<div id="mydiv">Regular old div</div>
Then in script:
document.getElementById('mydiv').onclick = function() {
alert('hello!');
}
They wouldn't set the onclick property directly, it would have been set in the GWT code or via another Javascript library.
The GWT documentation shows how to create handlers within a GWT Java app:
public void anonClickHandlerExample() {
Button b = new Button("Click Me");
b.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
// handle the click event
}
});
}
This will generate an HTML element and bind a click handler to it. However, in practice this has the same result as using document.getElementById('element').onclick() on an existing element in your page.
You can hook functions to the onclick event using JavaScript. Here's an example using jQuery:
$(document).ready(function(){
$("#div-id").click(function(){
/* Do something */
});
});
If you're interested in optimizing performance around this, you may need to investigate event delegation, depending on your situation.
A click event is generated for every DOM element within the Body. The event travels from the Body down to the element clicked (unless you are using Internet Explorer), hits the element clicked, and then bubbles back up. The event can be captured either through DOM element attributes, event handlers in the javascript, or attributes at any of the parent levels (the bubbling or capturing event triggers this).
I'd imagine they've just set it in a .js file.
Easily done with say jQuery with $(document).ready() for example.