JQMIGRATE: jQuery.fn.attr(selected) may use property instead of attribute - jQuery 1.9

JQMIGRATE: jQuery.fn.attr(selected) may use property instead of attribute - jQuery 1.9

WanderingZombieWanderingZombie Posts: 1Questions: 0Answers: 0
edited February 2013 in DataTables 1.9
[code]$('select option[value="'+oSettings._iDisplayLength+'"]', nLength).attr("selected", true);[/code]

should be

[code]$('select option[value="'+oSettings._iDisplayLength+'"]', nLength).prop("selected", true);[/code]

When using jQuery 1.9. jQuery Migrate 1.0.0 plugin, the following message is issued when .attr("selected", true) is used:

"JQMIGRATE: jQuery.fn.attr(selected) may use property instead of attribute"

Replies

  • allanallan Posts: 63,389Questions: 1Answers: 10,449 Site admin
    Thanks for flagging this up. Looking at the code, I don't actually understand why it isn't just using $().val():

    [code]
    $('select', nLength).val( oSettings._iDisplayLength );
    [/code]

    however, it does now. Change committed and it will be in the next release.

    Thanks,
    Allan
This discussion has been closed.