如何在Rails助手中使用jQuery(how to use jQuery in Rails helper)
我试图在Rails应用程序中使用jQuery UI中的tabs功能。 我正在使用帮助导航,我想保持这种方式。 我帮手的代码是:
def links_for_navigation html = "" html = <<HTML <ul> <li><a href="#tabs-1">Courses</a></li> <li><a href="#tabs-2">Parts</a></li> <li><a href="#tabs-3">Categories</a></li> </ul> <div id="tabs-1"><% link_to "Courses", courses_path %> <div id="tabs-2"><% link_to "Parts", parts_path %> <div id="tabs-3"><% link_to "Categories", categories_path %> HTML end
我的视图使用
<% links_for_navigation %>
提取代码我添加到我的
application.js
:jQuery(function() { jQuery("#tabs").tabs(); });
我的
application.html.erb
有:<%= stylesheet_link_tag 'courses', 'jquery-ui-1.8.13.custom.css' %> <%= javascript_include_tag :defaults %> <%= javascript_include_tag 'jquery-1.5.1.min.js', 'jquery-ui-1.8.13.custom.min.js', 'application' %>
当我尝试加载页面时,我
cannot find string HTML before EOF
。 我究竟做错了什么?I am trying to use the tabs function from jQuery UI in a Rails app. I am using a helper for the navigation and I would like to keep it that way. The code in my helper is:
def links_for_navigation html = "" html = <<HTML <ul> <li><a href="#tabs-1">Courses</a></li> <li><a href="#tabs-2">Parts</a></li> <li><a href="#tabs-3">Categories</a></li> </ul> <div id="tabs-1"><% link_to "Courses", courses_path %> <div id="tabs-2"><% link_to "Parts", parts_path %> <div id="tabs-3"><% link_to "Categories", categories_path %> HTML end
My view pulls in the code with
<% links_for_navigation %>
I added to my
application.js
:jQuery(function() { jQuery("#tabs").tabs(); });
And my
application.html.erb
has:<%= stylesheet_link_tag 'courses', 'jquery-ui-1.8.13.custom.css' %> <%= javascript_include_tag :defaults %> <%= javascript_include_tag 'jquery-1.5.1.min.js', 'jquery-ui-1.8.13.custom.min.js', 'application' %>
When I try to load the page I get
cannot find string HTML before EOF
. What am I doing wrong?
原文:https://stackoverflow.com/questions/6287342
最满意答案
谢谢大家的帮助。 我改变了
e.getMessage();
至
e.printStackTrace();
我看到异常是关于ssl证书。 所以我处理了,现在它工作。 谢谢你们。
Thank you all for trying to help. I've changed the
e.getMessage();
to
e.printStackTrace();
And I saw that the exception was about ssl certificate. So I handled that and now it works. Thank you all.
相关问答
更多-
问题发生在您在sendSms方法开始时创建PendingIntent对象的sendSms 。 你正在实施SendSMS作为一项活动,但我认为它不是必须的,并且它没有被正确初始化为一个活动,所以你看到了这个失败。 从你的sendingms类中取出extends Activity ,并将sendSms方法更改为如下启动: public class SendSms { public void sendSMS(Context context, String phoneNumber, String mess ...
-
Android:onResume()在HttpRequest上崩溃到Google地方信息(Android: onResume() crashes on HttpRequest to Google Places)[2022-04-09]
我已经解决了这个问题。 在我的自定义HttpTransport类中,我有一个final ApacheHttpTransport对象,每次createRequestFactory()方法时都会重用它。 问题似乎是当连接丢失,然后创建新连接时,它会尝试使用旧连接(沿着这些线路)。 因此,为了解决这个问题,我在createRequestFactory()方法中创建了一个新的ApacheHttpTransport对象。 I have solved the problem. In my custom HttpTran ... -
您的txtname和txtnumber为空 即 final EditText txtname=(EditText)findViewById(R.id.editText1); final EditText txtnumber=(EditText)findViewById(R.id.editText2); 当您尝试访问空引用时,您将获得NullPointerException 试着让他们这样 final EditText txtname=(EditText)v.findViewById(R.id.editT ...
-
正如Logcat日志中所述: 04-29 19:59:53.072:E / AndroidRuntime(546):android.os.NetworkOnMainThreadException 你执行testHTTP() ,这涉及主线程上的网络连接,这是不允许的。 将其移动到后台线程,或使用AsyncTask 。 As stated in the Logcat log: 04-29 19:59:53.072: E/AndroidRuntime(546): android.os.NetworkOnMainT ...
-
有时收到的异常可能为null ...因此在通过日志值打印时 Log.d(TAG, "add some string here" + ex.toString()); 避免空指针异常 Some times exception received may be null ... so while printing through log values Log.d(TAG, "add some string here" + ex.toString()); to avoid null pointer excepti ...
-
这一行在这里 btnSongList.setOnClickListener(new OnClickListener(){@Override public void onClick(View v) {visible();}}); 您从未为此特定视图调用findViewById() ,因此指针仍为null。 This line here btnSongList.setOnClickListener(new OnClickListener(){@Override public void on ...
-
您可能会尝试在主线程的doRequest()中执行联网操作。 在AsyncTask中运行你的代码https://developer.android.com/reference/android/os/AsyncTask.html下面的代码可能会帮助你 问题出在你的onPostExecute和对话框上。 你应该重写onPostExecute并且getDialog将返回AlertDialog。 每当您的请求成功时,异常必须为空。 检查我编辑的代码: class GetData extends AsyncT ...
-
在setContentView之后移动liste初始化: setContentView(R.layout.activity_main); liste = (ListView) findViewById(R.id.listView); 为什么NullPointerException? 您在以下行中调用null引用liste ssetAdapter上的liste : liste.setAdapter(adapter); liste为null,因为它在视图启动之前正在被初始化(绑定活动与视图)。 因此,fin ...
-
试试yourHttpRequest.abort() HttpGet和HttpPost实现了AbortableHttpRequest ,它有abort()方法 http://developer.android.com/reference/org/apache/http/client/methods/AbortableHttpRequest.html Try yourHttpRequest.abort() Both HttpGet and HttpPost implement AbortableHttpRequ ...
-
谢谢大家的帮助。 我改变了 e.getMessage(); 至 e.printStackTrace(); 我看到异常是关于ssl证书。 所以我处理了,现在它工作。 谢谢你们。 Thank you all for trying to help. I've changed the e.getMessage(); to e.printStackTrace(); And I saw that the exception was about ssl certificate. So I handled that ...