Reputation:
I have the following:
editCity: "/Admin/Citys/Edit?pk=0001I&rk=5505005Z"
$('#editCity')
.attr('title', "Edit City " + rk)
.data('disabled', 'no')
.data('href', editCity)
.removeClass('disabled');
When I check the HTML with developer tools I see this:
<div class="button dialogLink" id="editCity"
data-action="EditCity" data-disabled="yes"
data-entity="City" title="Edit City 5505005Z" ></div>
Everything is updated except the href. Anyone have an ideas what I am doing wrong?
Upvotes: 0
Views: 1541
Reputation: 2667
I think jQuery stores the data internally if they don't exist the first time you set them. If you really want to force it:
$("#editCity").attr("data-href",editCity)
Upvotes: 1
Reputation: 269
You cannot set a href attribute to a div. you could use data-href instead, or use a a-tag instead of a div.
Upvotes: -1
Reputation: 664434
Use
var editCity = "/Admin/Citys/Edit?pk=0001I&rk=5505005Z";
What you did was a labeled statement, consisting only of a string literal and missing a semicolon.
Btw, jQuery's .data()
method is not to be used for data-attributes, but just for associating JS objects with DOM elements.
Upvotes: 1