name spaced jquery

62 views
Skip to first unread message

Cory Gwin

unread,
Oct 25, 2011, 5:59:38 PM10/25/11
to writeCapture.js Users
Hello,

I am really excited about this plugin it is great! However I am
wondering if there is a clean way to set it up to use a name spaced
version of jQuery, I am going to be using this plugin in many other
developers enviroments and they may be using other versions of jQuery,
no jQuery or the $ may be for something else.

I am using yup nope to load jQuery as so
yepnope({
test: isAvailable("jQuery"),
nope: 'http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/
jquery.min.js',
yup: function(){
my_jQuery = jQuery;
},
complete: function(url, result, key){
if(isAvailable("_$")){
my_jQuery = $.noConflict(true);
} else {
bim_jQuery = jQuery;
}
operationOrder[1].call();
}
})
})

I have fixed the plugin by passing in my version of jquery in the
immediate function

})(my_jQuery,writeCapture.noConflict());

but wonder if there are cleaner ways, I also need to know how to
cleanly set this up for the main writeCapture plugin.

Thanks for the help!

Cory

noah

unread,
Oct 25, 2011, 6:15:09 PM10/25/11
to writecaptu...@googlegroups.com
Hi Cory,

So for your situation it would probably be better to use the nolib
support. That's just
https://raw.github.com/iamnoah/writeCapture/master/support/nolib-support.js
and https://raw.github.com/iamnoah/writeCapture/master/writeCapture.js
or the nolib download. See
https://github.com/iamnoah/writeCapture/wiki/Usage near the bottom for
the syntax when not using the jQuery plugin.

However, if you do want to give writeCapture a specific version of
jQuery, all you need to do is call jQuery.noConflict(true) after
including writeCapture:

<script src="jquery.js"> </script>
<script src="writeCapture.js"> </script>
<script>jQuery.noConflict(true);</script>

noConflict(true) will make it so that only writeCapture can see that
version of jQuery. Everything else will see whatever is included
before or after (if anything).

Cheers,
Noah

Cory Gwin

unread,
Oct 26, 2011, 9:57:34 AM10/26/11
to writecaptu...@googlegroups.com
I was looking into the no-lib library, but I could not find any documentation about how to use it. Does any exist?

Thanks,
Cory

Cory Gwin

unread,
Oct 26, 2011, 9:59:20 AM10/26/11
to writecaptu...@googlegroups.com
oh, duh thats the third link you sent :) I will see if I can figure this out. Thanks for the help!

On Oct 25, 2011, at 5:15 PM, noah wrote:

Cory Gwin

unread,
Oct 26, 2011, 10:27:38 AM10/26/11
to writecaptu...@googlegroups.com
Awesome, it seems to work great (I haven't tested all browsers yet)... People from the future, it is important to note that the no lib library has to come before the writecapture library. Also the writeCapture.html( function requires a jQuery style selector of an id, you cannot pass a getElementById selector as the library will error out saying it will only accept an id.

Cory Gwin

unread,
Oct 26, 2011, 10:29:25 AM10/26/11
to writecaptu...@googlegroups.com
Oh also of note to those from the future, the library requires that the page be fully loaded, otherwise you seem to get some odd behavior. jQuery makes this easy, but if you are not using jQuery check out this domready script - http://code.google.com/p/domready/

noah

unread,
Oct 26, 2011, 10:33:27 AM10/26/11
to writecaptu...@googlegroups.com
Only ID selectors are supported, but you can also pass an element (so
if you have another way of selecting, you can use that).

Cory Gwin

unread,
Oct 26, 2011, 10:35:20 AM10/26/11
to writecaptu...@googlegroups.com
I did a get element by id and passed it in as a var, but it tripped up here
if(!/^#[a-zA-Z0-9_:\.\-]+$/.test(s))
throw "nolib-support only allows id based selectors. selector=" + s;

noah

unread,
Oct 26, 2011, 10:42:08 AM10/26/11
to writecaptu...@googlegroups.com
Make sure you're passing a single element, without any sort of wrapper:

https://github.com/iamnoah/writeCapture/blob/master/support/nolib-support.js#L157

If you pass a jQuery object, it wont work.

Reply all
Reply to author
Forward
0 new messages