2014-04-30 6 views
0

나는 jquerymobile datebox customflip, plugin에서 일하고 있습니다. 나는 3 가지 문제를 겪고있다. 제목에서 첫 번째, 어떻게 제목을 '정의되지 않은'두 번째로 변경할 수 있습니다. 단추 텍스트를 어떻게 바꿀 수 있습니까? 내가 입력 텍스트 인덱스 대신jquery mobile datebox customflipbox 사용자 정의하는 방법

을 heres jsfiddle

코드

<h2>Custom Box Mode</h2> 

        <script type="text/javascript"> 
        jQuery.extend(jQuery.mobile.datebox.prototype.options, { 
         'customData': [ { 
          'input': true, 
          'name': '', 
          'data': ['Single', 'Separated', 'Involved', 'Married','Widowed','Lover','Other'] 
         }], 
         'useNewStyle': false, 
         'overrideStyleClass': 'ui-icon-dice' 
        }); 
        </script> 
        <style> 
        .ui-icon-dice { 
         background-image: url('http://dev.jtsage.com/jQM-DateBox/img/dice.png') !important; 
         background-repeat: no-repeat; 
         background-position: 99% 50%; 
        } 
        </style> 

        <div data-role="fieldcontain"> 
         <label for="cf">Custom</label> 
         <input name="cf" type="date" data-role="datebox" id="cf" data-options='{"mode": "customflip"}' /> 
        </div> 

답변

4

버튼 텍스트가 overrideCustomSet 속성에 의해 수정을 표시하는 방법 셋째.

var selectdata = ['Single', 'Separated', 'Involved', 'Married', 'Widowed', 'Lover', 'Other']; 

jQuery.extend(jQuery.mobile.datebox.prototype.options, { 
    "customData": [{ "input": true, "name": "", "data": selectdata }], 
    "customDefault": [0], 
    "useNewStyle": true, 
    "enablePopup": false, 
    "centerHoriz": true, 
    "centerVert": true, 
    "useFocus": true, 
    "useButton": false, 
    "useHeader": true, 
    "overrideCustomSet": "Looks Good", 
    "overrideCustomFormat": "%%" 
}); 

다른 두 가지 문제에 대해서는 datebox 이벤트를 처리 할 수 ​​있습니다. 이벤트 메서드가 postrefresh 일 때 대화 상자 제목을 설정하고 메서드가 set 일 때 배열에서 인덱스로 텍스트를 찾아서 입력 값으로 만듭니다.

$('#cf').on('datebox', function (e, p) { 
    if (p.method === 'postrefresh') { 
     $(".ui-datebox-container h1.ui-title").html("My Title"); 
    } 
    if (p.method === 'set') { 
     e.stopImmediatePropagation() 
     $(this).val(selectdata[p.value]); 
    } 
}); 

여기에 업데이트 된 FIDDLE

+0

첫째, 와우, 모르는 사람이 실제로 사용하던 것입니다. 시원한. 그리고 나는 감동했습니다, 당신은 내가하는 것보다 더 잘 알고있는 것 같습니다. –

+0

둘째, 머리글을 덮어 쓸 수있는 옵션을 추가합니다. 지금은 레이블 텍스트 또는 자리 표시 자 특성 중 하나입니다. 나는 그것을 코드화 가능하게 만들 것이다. –

+0

마지막으로 두 번째 기능은 필요하지 않습니다. "customFormat": "% X1"(% X1 ... = 숫자 인덱스, % Xa ... = 옵션 텍스트) –

관련 문제