因为我们不能再在家庭组件中使用javascript了。 我决定在自定义的visualforce页面中实现我的javascript。
我的javascript是一种自动填充功能,可以帮助我的用户开始输入邮政编码。 选择后,将设置BillingPostalCode和BillingCity。
我覆盖了"编辑页面" - 我在标签中添加了我的javascript。 按照文档和我的旧代码,我的自动完成工作正在运行。
但是当我在页面上加载输入字段的当前值时," BillingPostalCode"缺少:'(
这是我的visualforce页面:
<apex:page standardController="Account" extensions="cpSearch" tabstyle="Account" >
<link rel="stylesheet" href="https://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css"></link>
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.1/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css"></link>
<script src="/soap/ajax/15.0/connection.js" type="text/javascript"></script>
<script src="/soap/ajax/15.0/apex.js" type="text/javascript"></script>
<style>
.ui-autocomplete { max-height: 100px; overflow-y: auto; overflow-x: hidden; padding-right: 20px; }
html .ui-autocomplete { height: 100px;}
</style>
<script>
var stages ;
var staheArray;
$ = jQuery.noConflict();
$(function () {
console.log('step 0');
$($("[id*='acc17zip']").val($("[id*='BillingPostalCode']"))).autocomplete({
minLength: 3,
source: function(request, response) {
queryTerm = request.term;
console.log('step 1');
console.log(queryTerm);
cpSearch.searchCP2(queryTerm,function(result, event){
console.log('step 2');
if(event.status) {
staheArray = result.toString().split("+");
response(staheArray);
}
});
}
});
$( $("[id*='acc17zip']").val($("[id*='BillingPostalCode']").val())).on("autocompleteselect", function( event, ui ){
selectedArray = ui.item.value.split(" - ");
console.log('step 3');
$($("[id*='acc17zip']").val($("[id*='BillingPostalCode']").val())).val(selectedArray[0]);
$($("[id*='acc17city']").val($("[id*='billingcity']").val()) ).val(selectedArray[1]);
return false;
});
});
</script>
<apex:form >
<apex:inlineEditSupport showOnEdit="saveButton, cancelButton"
hideOnEdit="editButton" event="ondblclick"
changedStyleClass="myBoldClass" resetFunction="resetInlineEdit">
<apex:pageblock mode="edit" id="Doc" title="Modifier Compte">
<apex:pageblockbuttons >
<apex:commandbutton action="{!save}" value="Sauvegarder"></apex:commandbutton>
<apex:commandbutton action="{!cancel}" value="Annuler"></apex:commandbutton>
</apex:pageblockbuttons>
<apex:pageblocksection title="Informations sur le compte">
<apex:outputtext value=""></apex:outputtext>
<apex:inputfield value="{!Account.Phone}" ></apex:inputfield>
<apex:outputfield value="{!Account.owner.Name}"></apex:outputfield>
<apex:inputfield value="{!Account.fax}"></apex:inputfield>
<apex:inputfield value="{!Account.Name}" required="true"></apex:inputfield>
<apex:inputfield value="{!Account.Website}"></apex:inputfield>
<apex:outputfield value="{!Account.RecordType.Name}"></apex:outputfield>
<apex:inputfield value="{!Account.Adresse_email__c}"></apex:inputfield>
<apex:inputfield value="{!Account.ParentID}"></apex:inputfield>
<apex:outputtext value=""></apex:outputtext>
<apex:inputfield value="{!Account.URL_du_logo_de_la_societe__c}"></apex:inputfield>
<apex:outputtext value=""></apex:outputtext>
<apex:inputfield value="{!Account.type}"></apex:inputfield>
</apex:pageblocksection>
<apex:pageblocksection title="Informations supplémentaires">
<apex:inputfield value="{!Account.Categorie__c}"></apex:inputfield>
<apex:inputfield value="{!Account.Ownership}" ></apex:inputfield>
<apex:inputfield value="{!Account.Pays__c}"></apex:inputfield>
<apex:inputfield value="{!Account.SIRET__c}"></apex:inputfield>
<apex:inputfield value="{!Account.Metier__c}"></apex:inputfield>
<apex:inputfield value="{!Account.Code_APE__c}"></apex:inputfield>
<apex:inputfield value="{!Account.Description}"></apex:inputfield>
<apex:inputfield value="{!Account.NumberOfEmployees}"></apex:inputfield>
</apex:pageblocksection>
<apex:pageblocksection title="Coordonnées">
<apex:inputfield value="{!Account.billingCountryCode}"></apex:inputfield>
<apex:inputfield value="{!Account.ShippingCountryCode}"></apex:inputfield>
<apex:inputfield value="{!Account.billingStreet}"></apex:inputfield>
<apex:inputfield value="{!Account.ShippingStreet}"></apex:inputfield>
<apex:inputfield value="{!Account.billingState}"></apex:inputfield>
<apex:inputfield value="{!Account.ShippingState}"></apex:inputfield>
<apex:inputfield id="acc17zip" value="{!Account.BillingPostalCode}">{!Account.BillingPostalCode}</apex:inputfield>
<apex:inputfield value="{!Account.ShippingPostalCode}"></apex:inputfield>
<apex:inputfield id="acc17city" value="{!Account.billingcity}"></apex:inputfield>
<apex:inputfield value="{!Account.Shippingcity}"></apex:inputfield>
<apex:inputfield value="{!Account.Facturation_CEDEX__c}"></apex:inputfield>
<apex:outputtext value=""></apex:outputtext>
</apex:pageblocksection>
</apex:form>
</apex:page>