2013-07-25 205 views
0

。 js是一個名爲 的函數function helloWorld(){} 我應該怎樣在模型的index.erb上調用此函數?在我的應用程序中將Javascript集成到我的Rhodes應用程序

我試着寫函數在的application.js

$("#changePanel").click(function() { 
    var data = "foobar"; 
    $("#panel").hide().html(data).fadeIn('fast'); 
}); 

then I change my layout erb. at the following content 
<% if System::get_property('platform') == 'APPLE' || System::get_property('platform') == 'ANDROID' || System::get_property('platform') == 'WP7' || is_bb6 || System::get_property('webview_framework') =~ /^WEBKIT/ %> 
     <script src="/public/js/application.js" type="text/javascript"></script> 
     <script src="/public/jquery/jquery-1.6.4.min.js" type="text/javascript"></script> 
     <script src="/public/jquery/jquery.json-2.3.min.js" type="text/javascript"></script> 

and in my view i added 
<div data-role="page"> 

    <div data-role="header" data-position="inline"> 
    <h1>Model001s</h1> 
    <a href="<%= Rho::RhoConfig.start_path %>" class="ui-btn-left" data-icon="home" data-direction="reverse" <%= "data-ajax='false'" if is_bb6 %>> 
     Home 
    </a> 
    <a href="<%= url_for :action => :new %>" class="ui-btn-right" data-icon="plus"> 
     New 
    </a> 
    </div> 

     <div id="panel">test data</div> 
     <input id="incre" value="Change Panel" type="button"> </div> 
</div> 

我不知道什麼是錯。請幫我

回答

1

我沒有看到你的點擊事件觸發任何#changePanel。 我想,也許你應該改變:

<input id="incre" value="Change Panel" type="button"> </div>

<input id="changePanel" value="Change Panel" type="button"> </div>

相關問題