Skip to content

Instantly share code, notes, and snippets.

@dominicpacquing
Created December 20, 2012 08:04
Show Gist options
  • Save dominicpacquing/4343690 to your computer and use it in GitHub Desktop.
Save dominicpacquing/4343690 to your computer and use it in GitHub Desktop.
jQueryUI + jQuery.noConflict
(->
jQuery = undefined
scriptLoadHandler = ->
main()
main = ->
window.jQuery.getScript("http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/jquery-ui.min.js").done ->
jQuery = window.jQuery.noConflict(true)
jQuery(document).ready ($) ->
alert(jQuery.fn.jquery)
if window.jQuery is `undefined` or window.jQuery.fn.jquery isnt "1.8.2"
script_tag = document.createElement("script")
script_tag.setAttribute "type", "text/javascript"
script_tag.setAttribute "src", "http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"
if script_tag.readyState
script_tag.onreadystatechange = ->
scriptLoadHandler() if @readyState is "complete" or @readyState is "loaded"
else
script_tag.onload = scriptLoadHandler
(document.getElementsByTagName("head")[0] or document.documentElement).appendChild script_tag
else
jQuery = window.jQuery
main()
)()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment