AnsweredAssumed Answered

How to add jQuery UI to create view

Question asked by swaldinger on Mar 17, 2020
Latest reply on Mar 19, 2020 by Matt Marum

Hi all,

 

I'm having troubles to include jQuery UI autocomplete (https://jqueryui.com/autocomplete) functionality to SugarCRM.

 

I'm trying to extend the Lead Create View at  /custom/modules/Leads/clients/base/views/create/create.js on the "department" input field.
The Code below is what I tried, but only Alert 1 is shown and the autocomplete and the Alert 2 does not work. There is no error message. Also no effect if I change alert() to a console.log()

 

({
    extendsFrom: 'CreateView',

    initialize: function(options) {

        this.myAutoCompleteLogic();      
        this._super('initialize', [options]);
     
    },

    myAutoCompleteLogic : function() {
        alert("Alert 1 - myAutoCompleteLogic is called");
        var availableWords = [
            "ActionScript",
            "AppleScript",
            "Asp",
            // ... more Words
        ];

        // doesn't work
        $("input[name='department']").autocomplete({
            source: availableWords
        });

        // doesn't work
        $("input[name='department']").click(function() {
            alert( "Alert 2 - Handler for .click() called." );
        });
    },
});

 

This is the Source code of the department input element:

<input type="text" name="department" value="" maxlength="100" class="inherit-width" aria-label="Department">

 

Do you know how to solve this?
Am I at the right file or do I have to place my code at any other file?


Many thanks 

Stay Healthy and Best Regards

 

Sven

Outcomes