我遇到了类似的问题。我所做的是制作自己的文件并从我的 application.js 文件bip.purr.js
中删除了要求:best_in_place.purr
//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 不起作用,所以我也更改了它。如果它适合您,您应该查看原始来源。在制作自己的文件之前,无论如何你都应该这样做,但这就是我的样子(assets/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;
}