Company logo
  • Jobs
  • Bootcamp
  • About Us
  • For professionals
    • Home
    • Jobs
    • Courses
    • Questions
    • Teachers
    • Bootcamp
  • For business
    • Home
    • Our process
    • Plans
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Calculator

0

60
Views
How to alert selectize attr?

I'm using selectize plugin and trying to alert custom data-attribute.

I tried with several method but it alway indefined result My select list :

<select name="location_work{{counter}}" id="location_work{{counter}}" class="list_type_op" data-md-selectize-inline required>
    <option data-data='{"param": 0}'  value="1">Construction</option>
    <option data-data='{"param": 1,"name":"x"}' value="2">Puchase</option>
    <option data-data='{"param": 2,"name":"x-y"}' value="3">Warranty</option>
</select>

And my js function

    $(document).on('change', '.list_type_op', function () { 
        var selected_option = this.value;
        var nbParam =  $('option:selected', this).attr('data-param');
        alert(nbParam); //is indefined
    });

Select list is in Estimated price section on Type Column

Here my jsfiddle : Jsfiddle

7 months ago · Juan Pablo Isaza
1 answers
Answer question

0

Finally i get value of attribute with this :

$(document).on('change', '.list_type_op', function () { 
    var selected_option = this.value;
    var nbParam =  $(".selectize-dropdown-content").find(`[data-value='${selected_option}']`).attr('data-param');
    alert(nbParam);
});

I search attribute in html code.

7 months ago · Juan Pablo Isaza Report
Answer question
Find remote jobs