简单的书签只能在控制台中使用

问题描述 投票:0回答:1
<div id="element.incident.assigned_to" class="form-group " style="">
   <div class="" data-type="label" choice="0" type="reference" id="label.incident.assigned_to" nowrap="true"><label onclick="return labelClicked(this);" for="sys_display.incident.assigned_to" dir="ltr" class=" col-xs-12 col-md-3 col-lg-4 control-label"><span id="status.incident.assigned_to" aria-label="" data-dynamic-title="" mandatory="false" oclass="" class=" label_description"></span><span title="" class="label-text" data-html="false" data-original-title="Person primarily responsible for working this task">Assigned to</span></label></div>
   <div class="col-xs-10 col-sm-9 col-md-6 col-lg-5 form-field input_controls">
      <div ng-non-bindable="" class="hidden"><input type="hidden" id="sys_original.incident.assigned_to" name="sys_original.incident.assigned_to"></div>
      <input type="hidden" id="incident.assigned_to" name="incident.assigned_to" onchange="onChange('incident.assigned_to')" class="" mandatory="false" aria-required="false"><input type="hidden" id="sys_display.original.incident.assigned_to" name="sys_display.original.incident.assigned_to" value="">
      <div class="input-group ref-container "><input id="sys_display.incident.assigned_to" name="sys_display.incident.assigned_to" aria-labelledby="label.incident.assigned_to" type="search" autocomplete="off" autocorrect="off" value="" ac_columns="first_name;last_name;email" ac_order_by="name" data-type="ac_reference_input" data-completer="AJAXTableCompleter" data-dependent="assignment_group" data-dependent-value="781fcb1637ec83006eb3fa7b34990e1f" data-ref-qual="" data-ref="incident.assigned_to" data-ref-key="null" data-ref-dynamic="false" data-name="assigned_to" data-table="sys_user" class="form-control element_reference_input  " style="; " spellcheck="false" onfocus="if (!this.ac) addLoadEvent(function() {var e = gel('sys_display.incident.assigned_to'); if (!e.ac) new AJAXTableCompleter(gel('sys_display.incident.assigned_to'), 'incident.assigned_to', 'assignment_group', ''); e.ac.onFocus();})" aria-required="false"><span class="ref_dynamic_placeholder">A new record with this value will be created automatically</span><span class="input-group-btn"><button id="lookup.incident.assigned_to" name="lookup.incident.assigned_to" type="button" class="btn btn-default" title="Lookup using list" aria-haspopup="true" data-for="sys_display.incident.assigned_to" data-type="ac_reference_input" tabindex="-1" role="button" aria-label="Look up value for field: Assigned to" data-original-title="Lookup using list"><span class="icon icon-search" aria-hidden="true"></span></button></span></div>
      <script type="text/javascript">window.NOW = window.NOW || {};
         window.NOW.useHiddenDependent = 'true'.toLowerCase() === 'true';
      </script>
   </div>
   <div class="col-xs-2 col-sm-3 col-lg-2 form-field-addons">
      <a id="assign_to_me_incident.assigned_to" class="btn btn-default btn-ref icon" onclick="assignToMe('incident.assigned_to')" name="assign_to_me_incident.assigned_to" style="display:visible"><img border="0" src="images/icons/user_obj.gifx" title="Assign to me" alt="Assign to me" data-original-title="Assign to me"></a><script>function assignToMe(reference) {
         // Get the user reference field and populate the current user
         var s = reference.split('.');
         var referenceField = s[1];
         g_form.setValue(referenceField, 'TESTUSER');
         //g_form.setValue('state','2');
         }
      </script><span name=""><button id="viewr.incident.assigned_to" type="button" name="viewr.incident.assigned_to" title="Preview this record" aria-haspopup="true" style="display: none;" class="btn btn-default btn-ref icon icon-info" data-type="reference_popup" data-table="incident" data-form="sys_user.do" data-ref="incident.assigned_to" data-ref-key="null" data-view="" data-new-window="false" tabindex="-1" aria-label="Preview record for field: Assigned to" data-original-title="Preview this record"></button></span>
   </div>
</div>

这是上面代码的一部分

 <a id="assign_to_me_incident.assigned_to" class="btn btn-default btn-ref icon" onclick="assignToMe('incident.assigned_to')" name="assign_to_me_incident.assigned_to" style="display:visible"><img border="0" src="images/icons/user_obj.gifx" title="Assign to me" alt="Assign to me" data-original-title="Assign to me"></a>


<script>function assignToMe(reference) {
         // Get the user reference field and populate the current user
         var s = reference.split('.');
         var referenceField = s[1];
         g_form.setValue(referenceField, 'TESTUSER');
         //g_form.setValue('state','2');
         }

在控制台中,此代码在检查元素之后有效:

assignToMe('incident.assigned_to')

[尝试单击书签时,我得到了:

VM14031:1 Uncaught ReferenceError: assignToMe is not defined
    at <anonymous>:1:1
(anonymous) @ VM14031:1

任何提示?

javascript jquery bookmarklet
1个回答
0
投票
将此作为您的书签。
© www.soinside.com 2019 - 2024. All rights reserved.