无法在 onClick 事件上调用 JavaScript 函数 [英] Not able to call JavaScript function on onClick Event

查看:64
本文介绍了无法在 onClick 事件上调用 JavaScript 函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

**I have created a custom edit form for a SharePoint online custom list. Where I have created a custom button via which I will start a Workflow.
the issue is I am not able to call that function on button click. I have used a single comma also for the function call 

我为 SharePoint 在线自定义列表创建了自定义编辑表单.我在其中创建了一个自定义按钮,我将通过该按钮启动工作流程.问题是我无法在单击按钮时调用该函数.我在函数调用中也使用了一个逗号**

I have created a custom edit form for a SharePoint online custom list. Where I have created a custom button via which I will start a Workflow. The issue is I am not able to call that function on button click. I have used a single comma also for function call**

HTML 按钮代码:

    <td class="ms-toolbar" nowrap="nowrap" align="right">

    <input type="button" runat="server" value="Assign To Next Step" name="AssignToNextStep" onClick="startWorkflow()"/>

   </td>

JavaScript 函数代码为:

JavaScript Function Code is:

<script type="text/javascript">
function startWorkflow()
{
  alert("Inside");
  try
  {

  showInProgressDialog();

  var ctx = SP.ClientContext.get_current();

  var wfManager = SP.WorkflowServices.WorkflowServicesManager.newObject(ctx, ctx.get_web());

  var subscription = wfManager.getWorkflowSubscriptionService().getSubscription("My Workflow ID");

  ctx.load(subscription, 'PropertyDefinitions');

  ctx.executeQueryAsync(

  function(sender, args)

  {

  wfManager.getWorkflowInstanceService().startWorkflow(subscription, "");

  ctx.executeQueryAsync(

  function(sender, args)

  {

  closeInProgressDialog();

  },

  function (sender, args)

  {

  closeInProgressDialog();

  alert(errorMessage);

  });

  });

  }

  catch(ex)
  {
  alert(ex);
  dlg.close();
  }

}
</script>

推荐答案

那个函数超出了范围.我的意思是我只是改变了那个函数的位置.

That Function was out of Scope. I mean I just changed the place of that function.

这篇关于无法在 onClick 事件上调用 JavaScript 函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆