ich fand this jquery plugin für Inline-Bestätigung. Ich komprimiere/kombiniere alle js-Dateien mit einem für die Optimierung der http-Anfrage (das ist manuell). Jetzt oben ist diese Datei jquery Bibliothek 1.7.1 und dann habe ich Inline-Bestätigungs-Plugin. Dieses Plugin funktioniert nicht, wenn es sich in einer Datei mit jquery-Bibliothek befindet. Was ist mein Problem?jquery Bestätigungs-Plugin funktioniert nicht, wenn Merge/Compresse mit jquery
ex: normal: Apart (diese Arbeitete)
<script type="text/javascript" src="./js/jquery.js"></script>
<script type="text/javascript" src="./js/inline-confirmation.js"></script>
ex: comperss zu einer Datei (jquery + Inline-Bestätigung)
Nicht Workk<script type="text/javascript" language="javascript" src="./js/main.js"></script>
Inline Bestätigung Plugin:
jQuery.fn.confirm = function(options) {
options = jQuery.extend({
msg: 'Are you sure?',
stopAfter: 'never',
wrapper: '<span></span>',
eventType: 'click',
dialogShow: 'show',
dialogSpeed: '',
timeout: 0
}, options);
options.stopAfter = options.stopAfter.toLowerCase();
if (!options.stopAfter in ['never', 'once', 'ok', 'cancel']) {
options.stopAfter = 'never';
}
options.buttons = jQuery.extend({
ok: 'Yes',
cancel: 'No',
wrapper:'<a href="#"></a>',
separator: '/'
}, options.buttons);
// Shortcut to eventType.
var type = options.eventType;
return this.each(function() {
var target = this;
var $target = jQuery(target);
var timer;
var saveHandlers = function() {
var events = jQuery.data(target, 'events');
if (!events && target.href) {
// No handlers but we have href
$target.bind('click', function() {document.location = target.href});
events = jQuery.data(target, 'events');
} else if (!events) {
// There are no handlers to save.
return;
}
target._handlers = new Array();
for (var i in events[type]) {
target._handlers.push(events[type][i]);
}
}
// Create ok button, and bind in to a click handler.
var $ok = jQuery(options.buttons.wrapper)
.append(options.buttons.ok)
.click(function() {
// Check if timeout is set.
if (options.timeout != 0) {
clearTimeout(timer);
}
$target.unbind(type, handler);
$target.show();
$dialog.hide();
// Rebind the saved handlers.
if (target._handlers != undefined) {
jQuery.each(target._handlers, function() {
$target.click(this.handler);
});
}
// Trigger click event.
$target.click();
if (options.stopAfter != 'ok' && options.stopAfter != 'once') {
$target.unbind(type);
// Rebind the confirmation handler.
$target.one(type, handler);
}
return false;
})
var $cancel = jQuery(options.buttons.wrapper).append(options.buttons.cancel).click(function() {
// Check if timeout is set.
if (options.timeout != 0) {
clearTimeout(timer);
}
if (options.stopAfter != 'cancel' && options.stopAfter != 'once') {
$target.one(type, handler);
}
$target.show();
$dialog.hide();
return false;
});
if (options.buttons.cls) {
$ok.addClass(options.buttons.cls);
$cancel.addClass(options.buttons.cls);
}
var $dialog = jQuery(options.wrapper)
.append(options.msg)
.append($ok)
.append(options.buttons.separator)
.append($cancel);
var handler = function() {
jQuery(this).hide();
// Do this check because of a jQuery bug
if (options.dialogShow != 'show') {
$dialog.hide();
}
$dialog.insertBefore(this);
// Display the dialog.
$dialog[options.dialogShow](options.dialogSpeed);
if (options.timeout != 0) {
// Set timeout
clearTimeout(timer);
timer = setTimeout(function() {$cancel.click(); $target.one(type, handler);}, options.timeout);
}
return false;
};
saveHandlers();
$target.unbind(type);
target._confirm = handler
target._confirmEvent = type;
$target.one(type, handler);
});
}
Dank
in der komprimierten Datei. Hast du die jQuery-Bibliothek vor dem Plugin-Code? – rgin
Ja, Sicher. Ich erzähle dies meiner Frage: Jetzt oben ist diese Datei jquery 1.7.1 und dann habe ich Inline-Bestätigungs-Plugin – BBKing
Versuchen Sie, die ganze komprimierte Datei anzuzeigen. Wollen Sie Bibliothek und Plugin wirklich in einer Datei speichern? Ich meine, was ist, wenn es Updates gibt? – rgin