jquery UI 대화 상자의 단추에 대한 번역 된 레이블이 변수에 있습니다.jQuery UI 대화 상자 변수의 버튼
버튼 배열 키를 변수 자체로 채울 수 없으며 변수를 마치 문자열로 처리 할 수있는 방법이 없습니다.
translations['ok'] = 'ok';
translatinos['cancel'] = 'cancel';
// not working
jQuery('#foo').dialog({
buttons:
{
translations['ok']: function() { alert('foo-ok'); },
translations['cancel']: function() { alert('foo-cancel'); }
}
});
// working
jQuery('#bar').dialog({
buttons:
{
"Ok": function() { alert('bar-ok'); },
"Cancel": function() { alert('bar-cancel'); }
}
});
가변 배열 키와 함께 사용할 수있는 방법이 있습니까?
var buttonsOpts = {}
buttonsOpts[translations["ok"]] = function ....
buttonsOpts[translations["cancel"]] = function ....
jQuery('#bar').dialog({
buttons : buttonsOpts
});
는 희망이 도움이 : 당신이 시도 할 수
'translatinos' 철자가 의도적입니까, 아니면 오타입니까? –