Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Jan Brinker 77 posts 103 karma points
    Sep 29, 2013 @ 15:37
    Jan Brinker
    0

    ListComments ContactSurface Partials break jQuery UI

    Hi,

    once more while building my site I came across some more things that do not seem right. This time I'm talking about the output generated by these partials:

    uCommentsyListComments

    uCommentsyContactFormSurface

     

    I am trying to incorporate uBlogsy and thus also uCommentsy into my own Templates, which worked quite good up to this point. Both of those partials generate some invalid output that my Firefox 23.0.1 (OS X) does not like. On my site I have a jQuery UI Accordion that works well, as long as those partials are not called. If they are called it still works on Safari, but that's of course not the sense of it all. I currently don't have access to the files itself or I would check myself what exactly caused that problem, but until I have that it will probably take some time.

    While I was guessing what could be the cause of it, I looked through the html output and found those lines twice, both generated by the partials mentioned above. Generally I don't think it's a very good and clean idea to import scripts and stylesheets like that far down in the body, especially if it's done twice. Rather just do it in the template in the head once and be done with it.

    <link href="/css/uCommentsy.css" rel="stylesheet" type="text/css" />
        <script src="http://code.jquery.com/jquery.min.js" type="text/javascript"></script>
        <script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.10.0/jquery.validate.min.js"></script>
        <script src="http://ajax.aspnetcdn.com/ajax/mvc/3.0/jquery.validate.unobtrusive.min.js"></script>

    But back to the jQuery UI thing. When loading the page (with one or both of those partials rendering) jQuery UI is not loaded, although the script is included correctly (otherwise it would obviously still not work, if the uCommentsy partials were not rendered). One guess why that is would be that somehow the reloading of jQuery that way triggers a re-initialization and jQuery UI is unloaded.

    It's either that or it's some other HTML that those partials render that does not validate in HTML 5 (checked with the W3C validator and it gave me 5 errors for that section)

    Whichever it is, a fix would be great.

    Thanks a lot

    Jan

  • Anthony Dang 1404 posts 2558 karma points MVP 3x c-trib
    Sep 30, 2013 @ 17:36
    Anthony Dang
    0

    "Generally I don't think it's a very good and clean idea to import scripts and stylesheets like that far down in the body"

    I completely agree. I only did it like that so that it would be "in theory" easier for beginners as everything "should just work".

    I thought that some dev would be experienced enough to notice this (such as in your case). In which case, it's perfectly fine to modify the scripts.

    These are just js includes. Treat them as you would normally. Move them around the page if you wish, and just be aware of possible load order issues based on dependencies.

    I hope that helps.

     

     

Please Sign in or register to post replies

Write your reply to:

Draft