I am adding a custom menu item in SharePoint Online ECB. I am using following code.
function AddCustomUserActionToECB() {
var testt = "javascript:callChatApp();";
var CstomAName = $("#text1").val();
var clientContext = new SP.ClientContext();
var oWeb = clientContext.get_web();
var oList = oWeb.get_lists().getByTitle('Documents');
var userCustomActionColl = oList.get_userCustomActions();
var oUserCustomAction = userCustomActionColl.add();
oUserCustomAction.set_location('EditControlBlock');
oUserCustomAction.set_sequence(100);
oUserCustomAction.set_title(CstomAName);
oUserCustomAction.set_url(testt);
oUserCustomAction.update(); clientContext.load(userCustomActionColl); clientContext.executeQueryAsync(QuerySuccess, QueryFailure);
}
function QuerySuccess() {
console.log("Custom Action added to ECB menu.");
}
function QueryFailure() {
console.log('Request failed - ' + args.get_message());
}
The code is working fine. Now I have a javascript function which should be called on ECB item click. The function code is:
function callChatApp() {
// Some javascript code.
$('#AnotherButton').trigger('click',function(e){
// e.stopPropagation(); // Sample tried code
//e.preventDefault(); // Sample tried code
});
//return false; // Sample tried code
}
Here the button triggers, but the page get refreshed so my pop up get closed. I want to prevent the page refresh here.
I browsed SO and found so may solution but none of them worked in SharePoint.
How I can prevent page reloading on ECB menu item clicked?