javascriptember.js

How to select an input field in ember js via chrome console


Currently there is an input field that displays a search drop down as soon as I click on it , but If I store the field as a global variable and try temp1.select() in chrome console ( temp1 is the name of the global variable) it does not work However this works when the tab is in the background(not the current tab I am viewing), when I go to the current tab the drop down is already open

after temp1.select() If I click somewhere else on the screen except on the input field it simultaneously opens and closes the search drop down This could be due to the event stored in a stack but not flushed , But I am note sure how to force the flush of the events Is there any function that could do this ?

this is the html code

<input aria-label="Search Test" autocomplete="off" 
placeholder="Search Test" id="ember1168" class="ember-text-field 
input--text composable-select__input ember-view" type="text">

Solution

  • After trying out multiple commands I think this works for me, I think we have to focus and then click

    $(element).focus().trigger('click');
    

    element could be selected using Xpath here.

    In my case it was

    $(document.querySelectorAll("*[placeholder=\"Search test\"]")[0]).focus().trigger('click');