English 中文(简体)
页: 1 2. 令人振奋的成功信息?
原标题:Rails Best in Place Gem - Flash success message?

I m using the best_in_place gem (https://github.com/bernat/best_in_place) for in place editing in a Rails app. My controller has the line:

format.json { respond_with_bip(@user) }

灰色产生任何验证错误的纯净通知,但我也找不到成功更新的通知? 我在文件上似乎看不到这一点,而博爱与智者的回应使我看上去看上去是黑的。

任何帮助都将受到高度赞赏。

问题回答
$( .best_in_place ).best_in_place().bind( ajax:success , function(evt, data, status, xhr) {
       console.dir(evt);
       console.dir(data);
       console.dir(status);
       console.dir(xhr);
     // Use them how ever you need eg $("#yourdiv").text(data["message"]);
}); 

阁下

format.json { render :json => { :message => "Successfully Saved your Model" } } 

这取决于你在你的控制人员中做些什么,但是,你可以启动一项活动,以显示通知,例如,在麻省:一些地方。

Upon re-reading your question, I don t think this ll help you actually. But check out Flash Render Gem just in case. Here s the info on how to implement the gem.

我也遇到了类似的问题。 我做了些什么,使自己的<代码>bip.purr.js文档删除best_in_place.purr。 要求我提出申请。 js file:

//application.js
//= require jquery
//= require best_in_place
//= require jquery_ujs
//= require best_in_place.jquery-ui
//= require jquery.purr
//REMOVED / COMMENTED OUT THE NEXT LINE:
// require best_in_place.purr
// ADDED THIS LINE:
//= require bip.purr
//= require turbolinks
//= require bootstrap-sprockets
//= require_tree .

我的错误职能OOB没有发挥作用,因此我也改变了这种情况。 如果为你工作,请看。 你在提出自己的档案之前应该这样做,但这正是我们所看的(资产/javascripts/bp.purr.js):

/*
 * BestInPlace 3.0.0.alpha (2014)
 *
 * Depends:
 *  best_in_place.js
 *  jquery.purr.js
 */
/*global BestInPlaceEditor */

BestInPlaceEditor.defaults.purrErrorContainer = "<span class= bip-flash-error ></span>";
BestInPlaceEditor.defaults.purrSuccessContainer = "<span class= bip-flash-success ></span>";

//edited this binding to stop showing  Error Object object 
jQuery(document).on( best_in_place:error , function (event, request, error) {
     use strict ;
    // Display all error messages from server side validation
    var errors_string = "";
    jQuery.each(jQuery.parseJSON(request.responseText), function (index, value) {
        if (typeof value === "object") {
            $.each(value, function (i, v) {
                errors_string += i[0].toUpperCase() + i.slice(1) + " " + v + ". ";
            });
        } else {
            errors_string = value;
        }
        var container = jQuery(BestInPlaceEditor.defaults.purrErrorContainer).html(errors_string);
        container.purr();
    });
});

//added this binding for success messages:
jQuery(document).on( best_in_place:success , function (event, request, error) {
     use strict ;
    // Display all success messages from server side validation
    var msg = "Updated Successfully";
    var container = jQuery(BestInPlaceEditor.defaults.purrSuccessContainer).html(msg);
    container.purr();
});

而且,就幸运的是,一些基本的SCSS能够找到不同的东西:

// for best in place / purr styling
.purr {
  position: fixed;
  top: 60px;
  right: 100px;
  width: 500px;
  padding: 20px;
  &.bip-flash-error {
    background-color: red;
  }
  &.bip-flash-success {
    background-color: green;
  }
  border: solid 1px #dadada;
  border-radius: 6px;
  -moz-border-radius: 6px;
  -webkit-border-radius: 6px;
  -webkit-box-shadow: 4px 4px 15px 0px rgba(0, 0, 0, 0.75);
  -moz-box-shadow: 4px 4px 15px 0px rgba(0, 0, 0, 0.75);
  box-shadow: 4px 4px 15px 0px rgba(0, 0, 0, 0.75);
  &:first-letter {
    text-transform: uppercase
  }
;
  font-size: 20px;
  color: white;
  font-weight: bolder;
  text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black;
}

由于你正在与JSON做答复,所以没有闪电。 闪电在超文本网页上(可使用flash[:message] = “Success! Hooray,但根据JSON的要求,这些公司没有位置显示。





相关问题
rails collection_select vs. select

collection_select and select Rails helpers: Which one should I use? I can t see a difference in both ways. Both helpers take a collection and generates options tags inside a select tag. Is there a ...

SSL slowness in EC2

We ve deployed our rails app to EC2. In our setup, we have two proxies on small instances behind round-robin DNS. These run nginx load balancers for a dynamically growing and shrinking farm of web ...

Auth-code with A-Za-z0-9 to use in an URL parameter

As part of a web application I need an auth-code to pass as a URL parameter. I am currently using (in Rails) : Digest::SHA1.hexdigest((object_id + rand(255)).to_s) Which provides long strings like : ...

RubyCAS-Client question: Rails

I ve installed RubyCAS-Client version 2.1.0 as a plugin within a rails app. It s working, but I d like to remove the ?ticket= in the url. Is this possible?

activerecord has_many :through find with one sql call

I have a these 3 models: class User < ActiveRecord::Base has_many :permissions, :dependent => :destroy has_many :roles, :through => :permissions end class Permission < ActiveRecord::...

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

Text Editor for Ruby-on-Rails

guys which text editor is good for Rubyonrails? i m using Windows and i was using E-Texteditor but its not free n its expired now can anyone plese tell me any free texteditor? n which one is best an ...

How to get SQL queries for each user where env is production

I’m developing an application dedicated to generate statistical reports, I would like that user after saving their stat report they save sql queries too. To do that I wrote the following module: ...

热门标签