2013-10-21 34 views
13

jQuery tanımlı değil diyor bu hatayı alıyorum. Ben twitter bootstrap ve jQuery-UI kullanmak istiyorum. Benim <head> benim için gerekli CSS ve JS ekledim. JQuery-UI sayfasının 1.9.1 jQuery kullandığını ve en son sürümün 1.10.2 olduğunu fark ettim. Yani bir çeşit çatışma olduğunu varsayarak düşünüyorum. Twitter önyükleme jQuery gerektirir ve bu da hataya neden olabilir. Ya da belki yanlış bir şey yapıyorum.jQuery tanımlı değil twitter bootstrap

Başkanı:

<head> 
    <meta charset="utf-8" /> 
    <link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" /> 
    <link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-theme.min.css" /> 
    <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" /> 
    <script src="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script> 
    <script src="http://code.jquery.com/jquery-1.9.1.js"></script> 
    <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script> 
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> 

</head> 

Hata:

Uncaught ReferenceError: jQuery is not defined   bootstrap.min.js:6 
(anonymous function)         bootstrap.min.js:6 

enter image description here

+7

jQuery bootstrap önce listelenen gerekmektedir. –

+2

Neden jQuery'nin iki sürümünü kullanıyorsunuz? – j08691

+0

@ j08691 Eh jQuery UI site bu sürümü kullanmak için bağlantılı ve ben JS geriye dönük uyumluluk hakkında bazı bilgi baktı. İyi olduğunu okudum ama bazen hatalar olabilir, bu yüzden ikisini de dahil ettim. – Liondancer

cevap

45

Yük jQuery her şeyden önce! bootstrap yukarıda

<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" /> 
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-theme.min.css" /> 
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" /> 

<script src="http://code.jquery.com/jquery-1.9.1.js"></script> 
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> 

<script src="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script> 
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script> 
+7

ALways, CSS'yi yüklemeden önce CSS'yi yükleyin – Popnoodles

+0

@popnoodles - Thx bunun için, düzenlenmiş :) – tymeJV

+1

İdeal olarak javascript'i HTML'nizden sonra '' dan hemen önce yüklersiniz - o zamana kadar kullanılmaz ve sayfa yükünü bu şekilde hızlandırır. – Popnoodles

4
<script src="http://code.jquery.com/jquery-1.9.1.js"></script> 
<script src="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script> 

eklenti jquery js dosyası

4

Bunu test ettik ve bu düzen iyi iş gibi görünüyor.

  1. Yük CSS
  2. Yük jQuery
  3. Yük Bootstrap
  4. Yük jQuery UI
  5. Bunun nedeni 2 nedenlerden büyük olasılıkla
5

: Sen yüklüyorsunuz

  1. jQuery iki kere; Bunlardan birini (tercihen eski versiyon) kaldırın.
  2. jQuery dosyasını yüklemeden önce bootstrap.min.js dosyasını yüklüyorsunuz (belgeleri okuyun here). Yapmanız gereken şey

geçerli:

<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" /> 
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-theme.min.css" /> 
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" /> 

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" /> 
<script src="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js" /> 
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js" /> 
+1

jQuery'den önce bootstrap.min.js dosyası benim sorunumdu. Şerefe. – Icementhols