0

在我的应用程序中。js 是一个名为 function helloWorld() {} 的函数,我应该怎么做才能在模型的 index.erb 上调用这个函数?

我尝试在 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>

我不知道怎么了。请帮我

4

1 回答 1

1

我看不到#changePanel您的点击事件会触发。我想也许你应该改变:

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

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

于 2013-07-28T09:08:34.163 回答