I have a Bootstrap drop down list
Just replace:
$("#ulGenres li a").data("[pdsa-dropdown-val= " + id + "]")
with
$("#ulGenres li a").filter("[data-pdsa-dropdown-val=" + id + "]")
Working example:
function DataLoad() {
var id = $("#TourId").val();
$("#Details").load('/umbraco/Surface/Tour/GetTourDetails?tourId=' + id);
}
$(document).ready(function () {
DataLoad();
$("#ulGenres li a").on("click", function () {
// Get text from anchor tag
var id = $(this).data('pdsa-dropdown-val');
$("#TourId").val(id);
// Add text and caret to the Select button
var text = $(this).text();
$("#selectButton").html(text + ' ');
// Put text into hidden field from model
$("#SelectedText").val(text);
DataLoad();
});
var id = $("#TourId").val();
$("#ulGenres li a").filter("[data-pdsa-dropdown-val=" + id + "]").trigger("click");
//$("#ulGenres li:first-child a").trigger("click");
});
http://jsbin.com/bekihay/edit?html,js