asif
asif

Reputation: 279

How get the data of selected option

I am using this plugin:

https://www.jqueryscript.net/demo/Drop-Down-Combo-Tree/

enter image description here

I won't get the id of that how can I do it.?

there no proper documentation available for this. is there any approach i can get it.?

<input type="text" id="justAnotherInputBox"
 placeholder="Type to filter" ng-change="showSummery(this)"/>



$scope.showSummery = function (data) {
        console.log(data)
};

Upvotes: 0

Views: 1357

Answers (3)

Ali Rasouli
Ali Rasouli

Reputation: 1911

if you used bottom code to define combo tree:

    var comboTree2;
 comboTree2 = $('#justAnotherInputBox').comboTree({
        source: dataJson,
        isMultiple: false
    });

then you can used bottom code to get selected value id:

comboTree2._selectedItem.id

Upvotes: 0

Henk de Vries
Henk de Vries

Reputation: 49

You can put an onclick listener on the <li> below the <input>:

$('#justAnotherInputBox')
    .parents('div.comboTreeWrapper')
    .find('div.comboTreeDropDownContainer')
    .on('click','li.ComboTreeItemChlid',function() {
   var id=$(this).find('span').attr('data-id');
   /* the rest of your code */
});

Note the typo "ComboTreeItemChlid". It is also in the plugin.

Upvotes: 1

Pratheesh M
Pratheesh M

Reputation: 1078

Try This,

 <input type="text" id="justAnotherInputBox"
     placeholder="Type to filter" ng-change="showSummery()"/>



    $scope.showSummery = function () {
            console.log(document.getElementById("justAnotherInputBox").value)
    };

Upvotes: 1

Related Questions