Can I make an AutoComplete execute an action when I select the item?
Application Type
Traditional Web
Service Studio Version
11.11.15 (Build 48647)


Hi everyone! I have an autocomplete to add users as watchers to a certain object. To do that I used an AutoComplete widget and a button, when the user wants to add a watcher just search it on the input and then clicks on the plus button to add it to the list, but what I really wanted was that when the user clicked on the watcher on the AutoComplete widget it immediately added it to the list without needed to click on the plus button, like an "onSelectedItem" action.

I hope someone can help me with this doubt and thank you everyone!


Solution

step 1.

Add javascript to the page like below 

$(document).ready(function() {
    debugger;
           $(window).on('load', function() {
           debugger;
           $('ul.os-internal-ui-autocomplete').click(function() {
                $('.AddwatcherLnk')[0].click();
            })
        });
});


Step 2. Hide the button with display none and add class to this button "AddwatcherLnk" like below

this + plus button will call when you will click on the name list.

PLz open oml check the code and apply same in your OML.

Are you working with traditional or reactive? Because when I tried to add a reference from autocomplete then it is showing for reactive application.

Thanks for the reply! I'm working with traditional.

It would be helpful if you share your sample oml.


Plz check the attached OML. I hope it will solve your problem.

DummyTraditionalApp10.oml

It's exactly that what I want! Thanks a lot!

Can you explain what you did? I can't explore too much of the oml file beacuse it has dependecies problems with anoteher module called DummyTraditionalApp that I don't have.

Solution

step 1.

Add javascript to the page like below 

$(document).ready(function() {
    debugger;
           $(window).on('load', function() {
           debugger;
           $('ul.os-internal-ui-autocomplete').click(function() {
                $('.AddwatcherLnk')[0].click();
            })
        });
});


Step 2. Hide the button with display none and add class to this button "AddwatcherLnk" like below

this + plus button will call when you will click on the name list.

PLz open oml check the code and apply same in your OML.

Thanks a lot! It worked! I had to take the ajax refresh from the autocomplete widget, but it worked! Thanks!

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.