How to get the "value" from pickList?

jQuery UI Widgets
Post Reply
rgiaviti
Posts: 4
Joined: 21 Jan 2015, 14:37

23 Jan 2015, 14:40

I am using PrimeUI PickList and it's working fine, but I don't know how I can get the value of the target data of Pick List. Let me show an example. Here's my picklist:

Code: Select all

       var mySourceData = [{label: 'Label 1', value: 1}, {label: 'Label 2', value: 2}];
       var myTargetData = new Array();      

        $('#myPickList').puipicklist({
            filter: true,
            dragdrop: true,
            filterMatchMode: 'contains',
            sourceData: mySourceData,
            targetData: myTargetData
        });
        
        // Fired button when I want to save my target data
        $('#myPickList').click(function(){
             // How can I retrieve my target data here and get the value ID?
        });
Like I wrote in the comment inside the function, how can I retrieve my target data here and get the value ID?

HTML:

Code: Select all

<div id="atividadesPicklist">
    <select name="source"></select>
    <select name="target"></select>
</div>


rgiaviti
Posts: 4
Joined: 21 Jan 2015, 14:37

24 Jan 2015, 21:56

I asked this question on stackoverflow and got a answer. Here it is. It worked like a charm.

Code: Select all

$('#myPickListSaveButton').click(function () {
     var targetData = $.map($('select[name=target] option'), function (v) {
          return v.value; // maps the values and returns them in an array ["1", "2"]
     });
     console.log(targetData); 
});

Post Reply

Return to “PrimeUI”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 20 guests