jquery脚本与turbolinks不兼容

时间:2015-08-05 07:23:41

标签: javascript jquery ajax ruby-on-rails-4 turbolinks

我的应用中有一个索引,其视图包含一些过滤选项。选择这些后,将过滤结果。这很好,除了当第一次进入索引时,所有这些脚本都不起作用,并且需要重新加载页面才能正常运行。我曾尝试使用row[<column>]宝石,没有做任何事情。 有什么建议吗?

index.html.erb:

In [37]: df
Out[37]:
   X  Y  Count
0  0  1      2
1  0  1      2
2  1  1      2
3  1  0      1
4  1  1      2
5  0  0      1

In [38]: def func1(r):
   ....:     print(r['X'])
   ....:     print(r['Y'])
   ....:     return r
   ....:

In [39]: df.apply(func1,axis=1)
0
1
0
1
1
1
1
0
1
1
0
0
Out[39]:
   X  Y  Count
0  0  1      2
1  0  1      2
2  1  1      2
3  1  0      1
4  1  1      2
5  0  0      1

的application.js:

public void sendEmail(final String userName, final String password, final String host, final String html, final List<String> emails, String subject, String file) throws MessagingException
    {
        System.out.println("User Name: " + userName);
        System.out.println("Password: " + password);
        System.out.println("Host: " + host);

        //Get the session object  
        Properties props = new Properties();
        props.put("mail.smtp.host", host);
        props.put("mail.smtp.auth", "true");

        Session session = Session.getDefaultInstance(props,
                new javax.mail.Authenticator()
                {
                    @Override
                    protected PasswordAuthentication getPasswordAuthentication()
                    {
                        return new PasswordAuthentication(userName, password);
                    }
                });

        if (!emails.isEmpty())
        {
            //Compose the message  
            InternetAddress[] address = new InternetAddress[emails.size()];
            for (int i = 0; i < emails.size(); i++)
            {
                address[i] = new InternetAddress(emails.get(i));
            }

            MimeMessage message = new MimeMessage(session);
            message.setFrom(new InternetAddress(userName));
            message.setRecipients(Message.RecipientType.TO, address);
            message.setSubject(subject);

            MimeBodyPart messageBodyPart = new MimeBodyPart();

            Multipart multipart = new MimeMultipart();

            messageBodyPart = new MimeBodyPart();
            String fileName = "attachmentName";
            DataSource source = new FileDataSource(file);
            messageBodyPart.setDataHandler(new DataHandler(source));
            messageBodyPart.setFileName(fileName);
            multipart.addBodyPart(messageBodyPart);
            message.setContent(html, "text/html; charset=utf-8");
            message.setContent(multipart);
            //send the message  
            Transport.send(message);

            System.out.println("message sent successfully...");
        } else
        {
            System.out.println("No Recieptions");
        }

    }

index.js.erb的:

jquery.turbolinks

1 个答案:

答案 0 :(得分:0)

你为什么使用turbolinks?除非你有一个非常好的,经过深思熟虑的理由,除了turbolinks之外别无他法,我建议你摆脱它。