2013-10-05 119 views
0

HTML文件knockout.js和的.htaccess在Ubuntu 12.04 LTS

<div id="demo"> 
    <p>First name: <strong data-bind="text: firstName"></strong></p> 
    <p>Last name: <strong data-bind="text: lastName"></strong></p> 
    <button data-bind="click: myFunctionSave">Save</button> 
    <button data-bind="click: myFunctionCancel">Cancel</button> 
</div> 
<script type='text/javascript' src='ViewModel/knockout-2.3.0.js'></script> 
<script type='text/javascript' src='ViewModel/main.js'></script> 

JavaScript文件

function myFunctionSave() { 
    this.firstName = "save";this.lastName = "saveSurname"; 
} 
function myFunctionCancel() { 
    this.firstName = "cancel";this.lastName = "cancelSurname"; 
} 
    ko.applyBindings(new myFunctionSave()); 
    ko.applyBindings(new myFunctionCancel()); 

的.htaccess

我無法在Ubuntu創建的.htaccess 12.04 LTS 。我已經取消了它的權限,甚至在Apache中完成了所有操作,但仍然重定向到本地主頁主頁,並說「YES ITS WORKING」 但未重定向到index.html。

嘗試這種代碼,它正在 HTML文件

<div class='demo'> 
<button data-bind='click: save'>save</button> 
<button data-bind='click: cancel'>cancel</button> 
</div> 
<script type='text/javascript' src='ViewModel/knockout-2.3.0.js'></script> 
<script type='text/javascript' src='ViewModel/main.js'></script> 

JavaScript文件

var student = function() { 
    var self = this; 
    self.save = function() { alert("save"); }; 
    self.cancel = function() { alert("cancel"); }; 
}; 
ko.applyBindings(new student()); 

但爲什麼這個代碼不工作 HTML文件

<div class='demo'> 
<p>First name: <strong data-bind="text: firstName"></strong></p> 
<p>Last name: <strong data-bind="text: lastName"></strong></p> 
<button data-bind='click: save'>save</button> 
<button data-bind='click: cancel'>cancel</button> 
    </div> 
    <script type='text/javascript' src='ViewModel/knockout-2.3.0.js'></script> 
    <script type='text/javascript' src='ViewModel/main.js'></script> 

javscript文件

var student = function() { 
    var self = this; 
    self.save = function() { alert("save"); 
     self.firstName="save";  
     self.lastName="saveLastname"; }; 
    self.cancel = function() { alert("cancel"); 
     self.firstName="cancel"; 
     self.lastName="cancelLastname"; }; 
    }; 

ko.applyBindings(new student());

請幫助

回答

0

請確保您有在Apache中啓用(它不啓用開箱)的mod_rewrite。

+0

root @ ubuntu:〜#sudo a2enmod重寫 模塊重寫已啓用 我有這個先生,但我認爲它已經啓用,問題仍然抵制 – user2848966

相關問題