6

私はタミール語ベースのWebアプリケーションをやっています。私のアプリケーションでは、私は動的なフィールドを使ってユーザーの詳細を追加しました。ダイナミックフィールドには、これを行う方法やクラスに基づいたGoogle Translitatorの使い方が複数のidsを持っていますか?クラスIDに基づいてGoogleの翻字を行う方法

<script type="text/javascript" src="http://www.google.com/jsapi"></script> 
<script type="text/javascript"> 
    // Load the Google Transliteration API 
    google.load("elements", "1", { 
    packages: "transliteration" 
    }); 

    function onLoad() { 
    var options = { 
     sourceLanguage: 'en', 
     destinationLanguage: 'ta', 
     shortcutKey: 'ctrl+m', 
     transliterationEnabled: true 
    }; 

    // Create an instance on TransliterationControl with the required 
    var control = new google.elements.transliteration.TransliterationControl(options); 

    // Enable transliteration in the textfields with the given ids. 
    var ids = ['temrorary_address', 'permanant_address', 'bankbranch', 'member_name', 'father_husband', 'workingoffice_address', ]; 
    control.makeTransliteratable(ids); 

    // Show the transliteration control which can be used to toggle between 
    // English and Hindi and also choose other destination language. 
    control.showControl('translControl'); 
    } 
    google.setOnLoadCallback(onLoad); 
</script> 

答えて

1

makeTransliteratable入力は、同様にIDの配列が、要素の参照だけでなくてもよいです。 だから、書くことができます。

// Enable transliteration in the textfields with the given Class. 
var elements = document.getElementsByClassName('Type-Your-Class-Here'); 
control.makeTransliteratable(elements); 

をしかし、あなたは動的にフィールドを追加している場合、それは助けにはなりません。フィールドを動的に追加する場合は、新しいフィールドを追加するたびにcontrol.makeTransliteratableに電話する必要があります。

関連する問題