2017-01-27 22 views
1

Apex inputTextコントロールを使用して、jquery Date Pickerを使用して日付を入力しようとしています。JQuery Date Picker with VisualForce Apex inputText

ページコードと使用されているjavascript関数が以下に示されていますが、HTML入力コントロールを使用しているのにApexのinputTextコントロールで作業していないときにコードが正常に動作しているようです。

<apex:page showHeader="false" id="mypage" docType="html-5.0" controller="ControllerCalculateIncentive" sidebar="false" standardStylesheets="false"> 
    <html> 
    <head> 
    <apex:stylesheet value="{!URLFOR($Resource.styles, 'bootstrap.css')}" /> 
    <apex:stylesheet value="{!URLFOR($Resource.styles, 'scrum.css')}" /> 
    <apex:stylesheet value="{!URLFOR($Resource.styles, 'jquery-ui.css')}" /> 
    <apex:stylesheet value="{!URLFOR($Resource.styles, 'font-awesome.css')}" /> 
    <apex:includeScript value="{!URLFOR($Resource.styles, 'jquery-1.11.1.js')}"/> 
    <apex:includeScript value="{!URLFOR($Resource.styles, 'bootstrap.js')}"/> 
    <apex:includeScript value="{!URLFOR($Resource.styles, 'jquery.min.js')}"/> 
    <apex:includeScript value="{!URLFOR($Resource.styles, 'jquery-ui.js')}"/>  
    <script type="text/javascript"> 
     var j$ = jQuery.noConflict(); 
     j$(document).ready(function(){   
      var v= '{!$Component.mypage:frm:StartDate}'; 
      j$(v).datepicker({ 
       dateFormat: 'dd-mm-yyyy', 
       changeMonth: true, 
       changeYear: true}); 

      }); 
    </script> 
    </head> 
    <body> 
    <apex:form id="frm"> 
    <apex:inputText id="StartDate" value="{!StartDate}" ></apex:inputText> 
    <apex:form> 
    </body> 
    </html> 
</apex:page> 

答えて

0

あなたはコードの下で試してくださいでした:

j$(document).ready(function(){   
    var v= '#StartDate'; //putting id of the input field directly 
    j$(v).datepicker({ 
    dateFormat: 'dd-mm-yyyy', 
    changeMonth: true, 
    changeYear: true}); 

}); 
+0

内のコントロールを使用します

j$('input[id$="StartDate"]') 

このラインを使用して、<頂点:のinputText /> HTML

+0

ではなく、ドキュメントごとにHTML INPUTは同じIDで作成されます。次の例を参照してください。https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_inputText.htm – vijayP

+0

返信ありがとうございますが、まだ動作していません –

1

これはこれはjqueryの

関連する問題