2

This is the anchor that MVC 2 is creating:

<a class="syncLink" data-resultstarget="OmsToAdminPzInfoSyncResult" 
     href="/Sync/OmsToAdminPzInfoAjax" 
     onclick="Sys.Mvc.AsyncHyperlink.handleClick(this, new Sys.UI.DomEvent(event), { insertionMode: Sys.Mvc.InsertionMode.replace, updateTargetId: &#39;OmsToAdminPzInfoSyncResult&#39; });">
Pz Info</a>

And here's some jQuery. The first alert shows what it should, but the second shows undefied. I'm using jQuery 1.4.1

    $("a.syncLink").click(function () {
        alert($(this).attr("data-resultstarget"));
        alert($(this).data("resultstarget"));
    });

I know I asked this question before, but I don't have any camel casing here, so I'm not sure what the issue is.

1

2 Answers 2

8

This feature was added in jQuery 1.4.3.
You need to upgrade jQuery.

In older versions, you'll need to use .attr("data-resultstarget")

Sign up to request clarification or add additional context in comments.

4 Comments

@PaulD.Waite: No; it says 1.4.3. api.jquery.com/data As of jQuery 1.4.3 HTML 5 data- attributes will be automatically pulled in to jQuery's data object. The treatment of attributes with embedded dashes was changed in jQuery 1.6 to conform to the W3C HTML5 specification.
Docs say data was added in 1.2 - so that was only for local, in-memory storage—ie not reading from html5 attributes? docs.jquery.com/Data
Ok - got it. Data was extended in 1.4.3 to support html5 data attributes. Thank you for the quick answer @SLaks.
I went and reviewed the source code for 1.4.1 just to check, and there's definitely no data-attribute logic behind-the-scenes.
1

Upgrade your jQuery library. This feature was added in the later version.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.