Tag: bootstrap modal

通过输入上传完成后Rails4然后如何触发bootstrap模式?

我的Gemfile: gem ‘rails’, ‘4.2.8’ gem ‘carrierwave’, ‘~> 1.2’, ‘>= 1.2.2’ gem ‘mini_magick’, ‘~> 4.8’ gem ‘Jcrop’, ‘~> 0.1.0’ 现在我想使用form_for上传用户图片,我的show.html.erb : {:multipart => true} do |f| %> @user.name+”_avatar” %> @user.name+”_default” %> 我的user_controller.rb : def update @user = User.find(params[:id]) if @user.update_attributes(user_params) if params[:user][:picture].present? respond_to do |format| format.html do flash[:warning] = “Template missing” redirect_to @user end format.js { […]

bootstrap模式没有正确弹出

我正试图在铁轨上显示ruby上的模态。 我设置了一个视图按钮,所以无论何时单击,模式都会弹出。 但它没有正常工作。 正如您在图像上看到的那样,模态不应该变暗。 因此,我无法点击任何内容。 这是我的代码: index.html.erb . <%= link_to (' ‘).html_safe, edit_quotation_path(quotation), class: “btn btn-icon btn-fill btn-github”, title: “Edit Quotation ” + quotation.build_quotation_number, ‘data-toggle’ => ‘tooltip’, ‘data-placement’ => ‘top’ %> <%= link_to (' ‘).html_safe, quotation_path(quotation), data: {:confirm => ‘Are you sure you want to delete this quotation?’}, method: :delete, class: “btn btn-icon btn-fill btn-danger”, […]

Rails 4:escape_javascript渲染部分不起作用

在我的Rails 4应用程序中,我试图将一些视图显示为modals (使用Bootstrap模式),而不是常规的.html.erb视图。 例如,我有一个calendar模型,在控制器中有自定义analysis操作: def analysis @calendar = Calendar.find(params[:id]) respond_to do |format| format.js end end 按照本教程和其他教程中的说明 ,我尝试创建以下文件: # _dialog.html.erb × # _analysis.html.erb Analysis # analysis.js.erb // Add the dialog title $(‘#dialog h3’).html(“Calendar Analysis”); // Render calendar analysis $(‘.modal-body’).html(‘ ‘calendars/analysis’) %>’); // Show the dynamic dialog $(‘#dialog’).modal(“show”); // Set focus to the first element $(‘#dialog’).on(‘shown.bs.modal’, function […]

如何使用Javascript来操作模态内容?

我正在使用bootstrap模式和Ruby on Rails。 我能够显示模态罚款,但我无法使用Javascript来操作模态的内容。 我不确定我做错了什么,但我根本无法使用Javascript来影响模态的内容,直到我开始想知道DOM元素上是否存在不同的堆栈级别或者是否存在这样的事情甚至模态内容都是DOM的一部分。 这是我的app / views / home / index.haml: – url = @entry.class.to_s.downcase.singularize = link_to(send(“#{url}_path”, @entry), remote: true) do = yield #modals 视图包含打开模态的链接,在这种情况下,@ entry表示图像对象。 在图像控制器中我们有show动作,我用它来显示模态: def show authorize! :view, @image @can_destroy = can?(‘delete_asset’, @image) @can_edit = can?(‘edit_metadata’, @image) respond_to do |format| format.js end end 对于模态视图,我有app / view / show.js.erb $(“#modals”).html(”); $(‘#modals .modal’).modal(); […]

将RoR注册脚本添加到引导模式中

所以我试图在Bootstrap模式中创建一个注册脚本,但它失败了。 相同的脚本在其赢得的页面上工作,只是不确定为什么它在这里不起作用。 使用bootstrap有什么特别之处吗? 这是错误: 以下是模态内容 × Register Email “First name” %> Password “Last name” %> Password “Email” %> Password “Password” %> 这是我的用户控制器 class UsersController < ApplicationController def new @user = User.new end end 和用户模型 class User < ApplicationRecord has_secure_password end 最后我的db:为我的用户迁移文件 class CreateUsers < ActiveRecord::Migration def change create_table :users do |t| t.string :first_name t.string :last_name […]

如何使用Modals显示不同的post

我是RoR的新手,我最近遇到了一个问题,因为我试图以不同的模态显示不同的post。 为了上下文化,我有一个主页,每个post都会显示。 每个post都包含作者,内容,类似按钮和评论按钮。 我希望评论按钮打开一个模式,再次包含作者的姓名,内容和评论post的区域。 问题是我点击的每个模态包含相同的作者和相同的内容,即使我点击的评论按钮来自不同的post。 准确地说,模态中显示的内容来自最近发布的post。 告诉我你是否需要特别的东西,我很乐意用你要问我的代码编辑这篇文章。 显示post: Submitted ago Like Comment 这是我的模态: × Write your comment: Like Comment 这是我的JS脚本: $(document).ready(function(){ $(‘[data-toggle=”popover”]’).popover(); $(‘[data-toggle=”popover”]’).popover({ html : true}); }); $(‘#popover’).popover({ html : true, title: function() { return $(“#popover-head”).html(); }, content: function() { return $(“#popover-content”).html(); } });

Rails 4 – Bootstrap模态forms – 设置

我正在尝试按照本教程在我的Rails 4应用程序中设置包含嵌套表单的模式。 我有Project和Invite的模型。 协会是: Project has_many :invites Invite belongs_to :project 在我的views项目文件夹中,我做了一个名为new_invitation.html.erb的部分 × Modal header **here comes whatever you want to show!** Close Save changes 我正在尝试从我的项目显示页面链接到该项目,该页面包含: true, ‘data-toggle’ => “modal”, ‘data-target’ => ‘#modal-window’} %> 在我的app / javascripts文件夹中,我有一个名为new_invitation.js.erb的文件,其中包含: $(“#modal-window”).html(“”); 在我的应用程序js中,我有: //= require bootstrap/modal (与教程略有不同,因为我使用rails 4和bootstrap sass)。 在我的项目控制器中,我有: def new_invitation respond_to do |format| format.html format.js end end 我将路由从put更改为get动作(虽然我不明白这一步): […]