• Resolved muhammedswalihct

    (@muhammedswalihct)


    I want to add an “id” attribute to the input field of ASL to connect with another function on my website. Could you please tell me how to accomplish that?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author wpdreams

    (@wpdreams)

    Hi,

    That is not possible without editing the core plugin files. If this is required for a script, then using a different selector will work as well, without needing to edit the files.

    For example, if you need it within a jQuery script, then..

    $('.asl_m input.orig')

    ..will select the input field. Let me know if there is any specific code you need help with.

    Best regards,
    Ernest M.

    Thread Starter muhammedswalihct

    (@muhammedswalihct)

    Thanks for your answer. I am trying to enable Google Transliterate API on the plugin search field. This is the code from Google Transliterate.

    <script type=”text/javascript”>

    // Load the Google Transliterate API
    google.load(“elements”, “1”, {
    packages: “transliteration”
    });

    function onLoad() {
    var options = {
    sourceLanguage:
    google.elements.transliteration.LanguageCode.ENGLISH,
    destinationLanguage:
    [google.elements.transliteration.LanguageCode.HINDI],
    shortcutKey: ‘ctrl+g’,
    transliterationEnabled: true
    };

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

    // Enable transliteration in the textbox with id
    // ‘transliterateTextarea’.
    control.makeTransliteratable([‘transliterateTextarea’]);
    }
    google.setOnLoadCallback(onLoad);
    </script>

    So, I want to know what should I add to the code or replace “control.makeTransliteratable([‘transliterateTextarea’]);” to trigger the API on this plugin search field.

    Plugin Author wpdreams

    (@wpdreams)

    Hi!

    Okay, so based on this stack overflow thread, the makeTransliteratable(..) function can accept an element references instead of an ID array as well.

    Try changing then these lines:

    // 'transliterateTextarea'.
    control.makeTransliteratable(['transliterateTextarea']);

    to:

    // 'transliterateTextarea'.
    control.makeTransliteratable(jQuery('.asl_m input.orig').get(0));

    ..or if that does not work, then:

    // 'transliterateTextarea'.
    var elements = document.getElementsByClassName('orig');
    if ( elements.length > 0 ) {
        control.makeTransliteratable(elements);
    }

    One of these should work, if the documentation was correct.

    Best regards,
    Ernest M.

    Thread Starter muhammedswalihct

    (@muhammedswalihct)

    Thanks for your help :). It worked perfectly.

    Plugin Author wpdreams

    (@wpdreams)

    Neat! You are welcome!

    I will mark this as resolved then. Feel free to rate the plugin if you like it.

    All the best,
    Ernest M.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How to Add “id” attribute to Input field?’ is closed to new replies.