SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Enthusiast laresistance2's Avatar
    Join Date
    May 2011
    Posts
    86
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question to distinguish links that should be loaded with Ajax

    Hello to all,

    I make a website with some pages to be loaded with Ajax and the URL of these links must be distinguished by JavaScript.

    At first I had thought to make connections like this: <a rel="ajax" href="my-page-loaded-by-ajax.html">link</a> but it is unconventional because the value "ajax" does not exist for the rel attribute.

    I also thought for the attribute class="ajax" but it's not very clean since this attribute is used to style the page, not JavaScript.

    There is also the attribute id but the problem is that its value must be unique for the page.

    So I would like your advice whether in your opinion what is the attribute most appropriate for this kind of thing.

    Thank you!

  2. #2
    SitePoint Wizard bronze trophy chris.upjohn's Avatar
    Join Date
    Apr 2010
    Location
    Melbourne, AU
    Posts
    2,197
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Personally i would use the class attribute and use a value such as link-ajax which is perfectly valid and makes sense, using the rel attribute would be valid as well but of course as you said the value wouldn't be but in the past i have used the rel attribute before for things like this regardless of whether it passes validation or not because the markup is valid.

  3. #3
    SitePoint Enthusiast laresistance2's Avatar
    Join Date
    May 2011
    Posts
    86
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you for your reply but I found a more appropriate attribute with HTML5.

    http://html5doctor.com/html5-custom-data-attributes/

    A link like this: <a data-loading="ajax" href="my-page-loaded-by-ajax.html">link</a> is still more consistent.


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •