2013-07-15 70 views
0

Jquery ui datepicker不能用於點擊輸入。Datepicker jqueryui不能與require.js和backbone.js一起使用

main.js

require.config({ 
    baseUrl: "js", 
    paths: { 
     html5shiv: "libs/html5shiv", 
     jquery: "http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min", 
     jqueryui: "http://code.jquery.com/ui/1.10.3/jquery-ui", 
     tablesorter: "libs/jquery.tablesorter.min", 
     script: "script", 
     underscore: "libs/underscore.min", 
     backbone: "libs/backbone.min", 
     utils: "utils", 
     collectorModel: "models/collectorModel", 
     collectorCollection: "collections/collectorCollection", 
     tollectorRouter: "routers/tollectorRouter", 
     edit: "views/collector/tollector_edit", 
     index: "views/collector/collector_index", 
     neww: "views/collector/collector_new", 
     row: "views/collector/collector_row", 
     show: "views/collector/collector_show", 
     'templates': 'templates' 
    }, 
    shim: { 
     jqueryui: { 
      deps: ["jquery"], 
      exports: "Jqueryui" 
     }, 
     tablesorter: { 
      deps: ["jquery"], 
      exports: "TableSorter" 
     }, 
     script: { 
      deps: ["jquery", "jqueryui", "tablesorter"], 
      exports: "Script" 
     }, 
     jqueryui: { 
      deps: ["jquery"] 
     }, 
     underscore: { 
      exports: "_" 
     }, 
     backbone: { 
      deps: ["underscore", "jquery"], 
      exports: "Backbone" 
     } 
    } 

}); 

require(["backbone", "underscore", "collectorCollection", "collectorRouter", "script"], 
    function (Backbone, _, CollectorCollection, CollectorRouter) { 
     var collectors = new CollectorCollection(); 
     var router = new CollectorRouter({collectors: collectors}); 
     Backbone.history.start(); 
    }); 

模板:collector_edit.html

input type="text" class="inputs dateInput" name="endDate" placeholder="End date" value="<%= endDate %> 

scripts.js中

$(document).ready(function() { 
    $(".dateInput").datepicker({dateFormat: "dd/mm/yy"}); 
}); 

使用它之前骨幹工作,當使用requireJS RequireJS

回答

1

你的dep全球範圍內不再存在共同體,而只存在於需要它們的模塊中。嘗試改變你的腳本JS到:

define(['jqueryui'], function(jqueryui) { 
    $(document).ready(function() { 
    $(".dateInput").datepicker({dateFormat: "dd/mm/yy"}); 
    }); 

}) 
+0

我已經改變了script.js,但它不起作用。 – mstafkmx

+0

你有任何錯誤信息? – silkAdmin

+0

沒有,我用螢火蟲。 – mstafkmx

相關問題