$this->_name = $name;
}
else {
+ // CRM-15153 - FIXME this name translates to a DOM id and is not always unique!
$this->_name = CRM_Utils_String::getClassName(CRM_Utils_System::getClassName($this));
}
if (!isset(self::$_template)) {
self::$_template = CRM_Core_Smarty::singleton();
}
+ // Workaround for CRM-15153 - give each form a reasonably unique css class
+ $this->addClass(CRM_Utils_System::getClassName($this));
$this->assign('snippet', CRM_Utils_Array::value('snippet', $_GET));
}
$this->accept($renderer);
$content = $renderer->toArray();
$content['formName'] = $this->getName();
+ // CRM-15153
+ $content['formClass'] = CRM_Utils_System::getClassName($this);
return $content;
}
{literal}
<script type="text/javascript">
CRM.$(function($) {
- var roleId = $('input[name=activity_role]:checked', '#Search').val();
+ var $form = $('form.{/literal}{$form.formClass}{literal}'),
+ roleId = $('input[name=activity_role]:checked', $form).val();
if (roleId) {
$('.description .option-' + roleId).show();
}
{literal}
<script type="text/javascript">
CRM.$(function($) {
- var $form = $("#{/literal}{$form.formName}{literal}");
+ var $form = $("form.{/literal}{$form.formClass}{literal}");
$('input[name=unclosed_case_id]', $form).crmSelect2({
placeholder: {/literal}'{ts escape="js"}- select case -{/ts}'{literal},
minimumInputLength: 1,
{literal}
<script type="text/javascript">
CRM.$(function($) {
+ var $form = $('form.{/literal}{$form.formClass}{literal}');
function showHideMapAPIkey() {
var mapProvider = $(this).val();
if ( !mapProvider || ( mapProvider === 'OpenStreetMaps' ) ) {
- $('#Mapping tr.crm-map-form-block-mapAPIKey').hide( );
+ $('tr.crm-map-form-block-mapAPIKey', $form).hide( );
} else {
- $('#Mapping tr.crm-map-form-block-mapAPIKey').show( );
+ $('tr.crm-map-form-block-mapAPIKey', $form).show( );
}
}
$('#mapProvider').each(showHideMapAPIkey).change(showHideMapAPIkey);
{literal}
<script type="text/javascript">
CRM.$(function($) {
+ var $form = $('form.{/literal}{$form.formClass}{literal}');
$('.selector-rows').change(function () {
var options = {
'url': {/literal}"{crmURL p='civicrm/ajax/batch' h=0}"{literal}
};
- $("#Entry").ajaxSubmit(options);
+ $($form).ajaxSubmit(options);
});
$('#crm-container').on('keyup change', '*.selector-rows', function () {
var sourceUrl = {/literal}"{crmURL p='civicrm/ajax/rest' h=0 q='snippet=4&className=CRM_Campaign_Page_AJAX&fnName=voterList' }"{literal};
var searchVoterFor = {/literal}'{$searchVoterFor}'{literal};
- CRM.$( 'table.gotvVoterRecords', 'form#{/literal}{$form.formName}{literal}').dataTable({
+ CRM.$( 'table.gotvVoterRecords', 'form.{/literal}{$form.formClass}{literal}').dataTable({
"bFilter" : false,
"bAutoWidth" : false,
"bProcessing": true,
{literal}
<script type="text/javascript">
CRM.$(function($) {
- var $form = $("#{/literal}{$form.formName}{literal}");
+ var $form = $("form.{/literal}{$form.formClass}{literal}");
$('input[name=link_to_case_id]', $form).crmSelect2({
placeholder: {/literal}'{ts escape="js"}- select case -{/ts}'{literal},
minimumInputLength: 1,
<script type="text/javascript" >
CRM.$(function($) {
- var $form = $("#{/literal}{$form.formName}{literal}");
+ var $form = $("form.{/literal}{$form.formClass}{literal}");
var action = "{/literal}{$action}{literal}";
$('.crm-accordion-body').each( function() {
}
});
{/literal}{* // Enforce unique is_primary fields *}{literal}
- cj(':checkbox[id*="[is_primary"]', 'form#Address_{/literal}{$blockId}{literal}').change(function() {
+ cj(':checkbox[id*="[is_primary"]', 'form[name=Address_{/literal}{$blockId}{literal}]').change(function() {
if (this.defaultChecked) {
cj(this).crmError("{/literal} {ts escape='js'}Please choose another address to be primary before changing this one.{/ts}{literal}");
cj(this).prop('checked', true);
}
});
{/literal}{* // Reset location_type_id when cancel button pressed *}{literal}
- cj(':submit[name$=cancel]', 'form#Address_{/literal}{$blockId}{literal}').click(function() {
+ cj(':submit[name$=cancel]', 'form[name=Address_{/literal}{$blockId}{literal}]').click(function() {
var container = cj(this).closest('div.crm-inline-edit.address');
var origValue = container.attr('data-location-type-id') || '';
container.data('location-type-id', origValue);
{literal}
CRM.$(function($) {
var
- $form = $("form#{/literal}{$form.formName}{literal}"),
+ $form = $("form.{/literal}{$form.formClass}{literal}"),
relationshipData = {/literal}{$relationshipData|@json_encode}{literal};
$('[name=relationship_type_id]', $form).change(function() {
var
{literal}
CRM.$(function($) {
- var $form = $("#{/literal}{$form.formName}{literal}");
+ var $form = $("form.{/literal}{$form.formClass}{literal}");
$('.add-cc-link', $form).click(function(e) {
e.preventDefault();
{literal}
<script type="text/javascript">
CRM.$(function($) {
- var $form = $('form#{/literal}{$form.formName}{literal}');
+ var $form = $('form.{/literal}{$form.formClass}{literal}');
$('#format_id', $form).on('change', function() {
selectFormat($(this).val());
});
{literal}
CRM.$(function($) {
- var $form = $("#{/literal}{$form.formName}{literal}");
+ var $form = $("form.{/literal}{$form.formClass}{literal}");
$("#contact_id", $form).change(checkEmail);
checkEmail( );
{literal}
<script type="text/javascript">
CRM.$(function($) {
- var $form = $("#{/literal}{$form.formName}{literal}");
+ var $form = $("form.{/literal}{$form.formClass}{literal}");
$('#showPCP, #showSoftCredit').click(function(){
return showHideSoftCreditAndPCP();
});
<script type="text/javascript">
var fieldName = "{/literal}{$field}{literal}";
var tsLocale = "{/literal}{$tsLocale}{literal}";
-cj('#Form').submit(function() {
+var $form = $('form.{/literal}{$form.formClass}{literal}');
+cj($form).submit(function() {
cj(this).ajaxSubmit({
beforeSubmit: function (formData, jqForm, options) {
var queryString = cj.param(formData);
- var postUrl = cj('#Form').attr('action');
+ var postUrl = cj($form).attr('action');
cj.ajax({
type : "POST",
url : postUrl,
{literal}
<script type="text/javascript">
CRM.$(function($) {
- $('#template_id', '#EventInfo').change(function() {
+ var $form = $('form.{/literal}{$form.formClass}{literal}');
+ $('#template_id', $form).change(function() {
$('#crm-main-content-wrapper')
.crmSnippet({url: CRM.url('civicrm/event/add', {action: 'add', reset: 1, template_id: $(this).val()})})
.crmSnippet('refresh');
}
);
- cj('#Participant').on("click",'.validate',
+ cj('form[name=Participant]').on("click", '.validate',
function(e) {
var userSubmittedStatus = cj('#status_id').val();
var statusLabel = cj('#status_id option:selected').text();
{literal}
CRM.$(function($) {
- var $form = $('form#{/literal}{$form.formName}{literal}');
+ var $form = $('form.{/literal}{$form.formClass}{literal}');
// don't show cart related statuses if it's disabled
{/literal}{if !$enableCart}{literal}
{literal}
<script type='text/javascript'>
CRM.$(function($) {
+ var $form = $('form.{/literal}{$form.formClass}{literal}');
cj('.total_amount-section').remove();
- cj('#ParticipantFeeSelection').submit(function(e) {
+ cj($form).submit(function(e) {
var partiallyPaid = {/literal}{$partiallyPaid}{literal};
var pendingRefund = {/literal}{$pendingRefund}{literal};
var statusId = cj('#status_id').val();
function allowGroupOnWaitlist( participantCount, currentCount )
{
- var formId = {/literal}'{$formId}'{literal};
+ var formId = {/literal}'{$formName}'{literal};
var waitingMsg = {/literal}'{$waitingMsg}'{literal};
var confirmedMsg = {/literal}'{$confirmedMsg}'{literal};
var paymentBypassed = {/literal}'{$paymentBypassed}'{literal};
{literal}
<script type="text/javascript">
CRM.$(function($) {
- var $form = $("#{/literal}{$form.formName}{literal}");
+ var $form = $("form.{/literal}{$form.formClass}{literal}");
$form
.on('click', '.crm-clear-attachment', function(e) {
e.preventDefault();
*}
{* Initialize jQuery validate on a form *}
{* Extra params and functions may be added to the CRM.validate object before this template is loaded *}
-{if !$crm_form_validate_included and $smarty.get.snippet neq 'json' and $form and $form.formName}
+{if !$crm_form_validate_included and $smarty.get.snippet neq 'json' and $form and $form.formClass}
{assign var=crm_form_validate_included value=1}
{literal}
<script type="text/javascript">
CRM.$(function($) {
- $("#{/literal}{$form.formName}{literal}").crmValidate();
+ $("form.{/literal}{$form.formClass}{literal}").crmValidate();
});
</script>
{/literal}
<script type="text/javascript" src="{$config->resourceBase}packages/jquery/plugins/jquery-fieldselection.js"></script>
<script type="text/javascript">
-cj('form#{$form.formName}').data('tokens', {$tokens|@json_encode});
+cj('form.{$form.formClass}').data('tokens', {$tokens|@json_encode});
var text_message = null;
var html_message = null;
var isPDF = false;
}
// Initialize token selector widgets
- var form = $('#{/literal}{$form.formName}{literal}');
+ var form = $('form.{/literal}{$form.formClass}{literal}');
$('input.crm-token-selector', form)
.addClass('crm-action-menu')
.change(insertToken)
{if $context eq 'standalone' and $outBound_option != 2 }
{literal}
CRM.$(function($) {
- var $form = $("#{/literal}{$form.formName}{literal}");
+ var $form = $("form.{/literal}{$form.formClass}{literal}");
$("#contact_id", $form).change(checkEmail);
checkEmail( );
{literal}
//keep read only always checked.
CRM.$(function($) {
- var $form = $("#{/literal}{$form.formName}{literal}");
+ var $form = $("form.{/literal}{$form.formClass}{literal}");
var allowAutoRenew = {/literal}'{$allowAutoRenew}'{literal};
var alreadyAutoRenew = {/literal}'{$alreadyAutoRenew}'{literal};
if ( allowAutoRenew || alreadyAutoRenew ) {
{if $context eq 'standalone' and $outBound_option != 2 }
{literal}
CRM.$(function($) {
- var $form = $("#{/literal}{$form.formName}{literal}");
+ var $form = $("form.{/literal}{$form.formClass}{literal}");
$("#contact_id", $form).change(checkEmail);
checkEmail( );
<script type="text/javascript" >
{literal}
CRM.$(function($) {
- var $form = $("#{/literal}{$form.formName}{literal}");
+ var $form = $("form.{/literal}{$form.formClass}{literal}");
$('select[name=name]', $form).change(function() {
var url = {/literal}"{$refreshURL}"{literal} + "&key=" + this.value;
$(this).closest('.crm-ajax-container, #crm-main-content-wrapper').crmSnippet({url: url}).crmSnippet('refresh');
</style>
<script type="text/javascript">
(function($, _){{/literal}
- var entityID={$entityID};
- var entityTable='{$entityTable}';
+ var entityID={$entityID},
+ entityTable='{$entityTable}',
+ $form = $('form.{$form.formClass}');
{literal}
CRM.updateContactSummaryTags = function() {
var tags = [];
tags = tags.concat(setTags);
});
// contact summary tabs and search forms both listen for this event
- $('#Tag').closest('.crm-ajax-container').trigger('crmFormSuccess', {tabCount: tags.length});
+ $($form).closest('.crm-ajax-container').trigger('crmFormSuccess', {tabCount: tags.length});
// update summary tab
$("#contact-summary #tags").html(tags.join(', '));
};
{* Controller for 'Rows Per Page' *}
{if $location eq 'bottom' and $pager->_totalItems > 25}
<div class="form-item float-right">
- <label for="{$form.formName}-rows-per-page-select">{ts}Rows per page:{/ts}</label>
- <input class="crm-rows-per-page-select" id="{$form.formName}-rows-per-page-select" type="text" size="3" value="{$pager->_perPage}"/>
+ <label for="{$form.formClass}-rows-per-page-select">{ts}Rows per page:{/ts}</label>
+ <input class="crm-rows-per-page-select" id="{$form.formClass}-rows-per-page-select" type="text" size="3" value="{$pager->_perPage}"/>
</div>
<div class="clear"></div>
{/if}
CRM.$(function($) {
{/literal}
var
- $form = $('#{$form.formName}'),
+ $form = $('form.{$form.formClass}'),
numPages = {$pager->_response.numPages},
currentPage = {$pager->_response.currentPage},
perPageCount = {$pager->_perPage},