В моем _MainLayout (parentlayout) я ссылался на несколько JS-файлов.
Частичные представления добавляются в div с использованием следующих функций javascript / jquery:
$.ajax(link, {
dataType: "html",
cache: false,
success: function(data, textStatus, jqXHR) {
return pageDownloaded(data, a);
},
complete: function (jqXHR, textStatus) {
//add .on event
}
});
и
function pageDownloaded(data, anchor){
var link = anchor.attr("href").replace(/^\#/, ""),
title = anchor.attr("title"),
id = link.replace(/[\/\.]/,"-"),
target = "#main-content",
div = $('<div style="left: 100%" id="'+id+'">'+data+'</div>').appendTo($(target));
$("#wrapper > section > section > header h1").html(title);
if ($('#wrapper > section > section').css('position')=='absolute') {
$("> div:last", target).css({left: 0, position: 'relative'}).siblings().remove();
$('#wrapper > section > section').show().animate({left: 0}, 300, "easeInOutQuart", function(){$(this).css('left',0);});
} else {
/* $("> div", target).animate({left: "-=100%"}, "slow", "easeInOutQuart", function(){
$(this).css('left',0);
$("> div:last", target).css({position: 'relative'}).siblings().remove();
});*/
$("> div", target).animate({ left: "-=100%" },500, function () {
$(this).css('left', 0);
$("> div:last", target).css({ position: 'relative' }).siblings().remove();
});
}
$(window).trigger('drilldown');
}
Проблема в том, что если я установил это в JS-файл, загруженный моей главной страницей (действия по умолчанию, добавляемые на каждую страницу (dateinput, ...))
(function($){
$.fn.placeholder = function(options) {
return this.each(function() {
if ( !("placeholder" in document.createElement(this.tagName.toLowerCase()))) {
var $this = $(this);
var placeholder = $this.attr('placeholder');
$this.val(placeholder).data('color', $this.css('color')).css('color', '#aaa');
$this
.focus(function(){ if ($.trim($this.val())===placeholder){ $this.val('').css('color', $this.data('color'))} })
.blur(function(){ if (!$.trim($this.val())){ $this.val(placeholder).data('color', $this.css('color')).css('color', '#aaa'); } });
}
});
};
})(jQuery);
$(document).ready(function() {
$('input[placeholder]', target).placeholder();
$("input[type=date]", target).dateinput();
$("input:checkbox,input:radio,select,input:file", target).uniform();
});
У меня естьсослаться на это снова в моем PartialView.Я также должен снова сослаться на файлы jquery.min.js, ...
Как я могу решить эту проблему дублирования?