Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #18070 > unrolled thread
| Started by | real-not-anti-spam-address@apple-juice.co.uk (D.M. Procida) |
|---|---|
| First post | 2013-01-11 10:35 +0000 |
| Last post | 2013-01-11 20:43 +0100 |
| Articles | 3 — 3 participants |
Back to article view | Back to comp.lang.javascript
$(document) and jQuery(document) real-not-anti-spam-address@apple-juice.co.uk (D.M. Procida) - 2013-01-11 10:35 +0000
Re: $(document) and jQuery(document) Scott Sauyet <scott.sauyet@gmail.com> - 2013-01-11 04:12 -0800
Re: $(document) and jQuery(document) Eric Bednarz <bednarz@fahr-zur-hoelle.org> - 2013-01-11 20:43 +0100
| From | real-not-anti-spam-address@apple-juice.co.uk (D.M. Procida) |
|---|---|
| Date | 2013-01-11 10:35 +0000 |
| Subject | $(document) and jQuery(document) |
| Message-ID | <1kwj3yx.lhvkrz1vz23l5N%real-not-anti-spam-address@apple-juice.co.uk> |
I had a widget, which broke after some other things were updated.
It was saying:
TypeError: 'undefined' is not a function (evaluating '$('#id_conta
cts_and_people-phonecontact-content_type-object_id-0-label').combo
box()')
Last night, I finally managed to fix it, after noticing that this script
(which is injected into the HTML body as many times as required for each
widget) began:
$(document).ready(function(){
while others I had seen began:
jQuery(document).ready(function($){
Changing it to the latter form made it work.
The only thing is, I don't really understand what was wrong, or how
doing that fixed it.
I understand that a jQuery conflict of some kind meant that jQuery was
unable to find the function "combobox()" and that probably this was
because of the way the template was loading JavaScript files.
But I don't understand what the changes actually mean, or what they do.
If someone can explain what is going on in this example, that would be
really helpful.
Thanks,
Daniele
--
Kraftwerk Consolation Night
20.00 1st March 2013 Chapter Arts Centre Cardiff
Eight different live ensembles playing the songs of Kraftwerk to ease
the disappointment of being unable to get tickets to see them in London
[toc] | [next] | [standalone]
| From | Scott Sauyet <scott.sauyet@gmail.com> |
|---|---|
| Date | 2013-01-11 04:12 -0800 |
| Message-ID | <15ec4992-4cff-4bef-a3d0-ca039ce3e172@u19g2000yqj.googlegroups.com> |
| In reply to | #18070 |
D.M. Procida wrote:
> [ ... ]
> $(document).ready(function(){
> [ ... ]
> jQuery(document).ready(function($){
>
> Changing it to the latter form made it work.
You're not generally very likely to get much help that specific to
jQuery here. You might want to check in their help forums. jQuery
and most general-purpose libraries are not well-thought of on
comp.lang.javascript.
That said, from what I've seen of jQuery, usually `$` is simply an
alias to `jQuery` unless specifically overwritten. The latter syntax
is a way to more comfortably share the global namespace with other
libraries that might also want to define `$`. So if you're not
including other libraries, and not redefining `$` yourself, I have no
idea why one would work and not the other.
-- Scott
[toc] | [prev] | [next] | [standalone]
| From | Eric Bednarz <bednarz@fahr-zur-hoelle.org> |
|---|---|
| Date | 2013-01-11 20:43 +0100 |
| Message-ID | <m2d2xbqzd7.fsf@nntp.bednarz.nl> |
| In reply to | #18071 |
Scott Sauyet <scott.sauyet@gmail.com> writes:
> D.M. Procida wrote:
>> [ ... ]
>> $(document).ready(function(){
>> [ ... ]
>> jQuery(document).ready(function($){
>>
>> Changing it to the latter form made it work.
> [...] So if you're not
> including other libraries, and not redefining `$` yourself, I have no
> idea why one would work and not the other.
http://api.jquery.com/jQuery.noConflict/
(might be called in included third party code, copy and pasted by the OP
himself, or whatnot)
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.javascript
csiph-web