问题
两个容器的 Options.whatever(options.slideDirection) 值保持不变,而不是例如: slideSpeed : 800 -> container1, slideSpeed : 700 -> container2 当 populateContent() 调用 runSlider() 但如果直接调用 runSlider 则保持正确。
脚本调用
$('#container1').slide({
service : "services/service1.json",
slideInterval : 2000,
slideSpeed : 800,
slideDirection : 'right'
});
$('#container2').slide({
service : "services/service2.json",
slideInterval : 7000,
slideSpeed : 200,
slideDirection : 'left'
});
插入
$.fn.slide = function(settings) {
var options = {
service : '',
slideInterval : 5000,
slideSpeed : 800,
slideDirection : 'right'
};
$.extend(options , settings);
jQuery.populateContent = function(serviceUrl,elm) {
$.runSlider(elm);
});
jQuery.runSlider = function(el) {
console.log(options.slideDirection); //***always option value remains the same, shows left always...
});
return $(this).each(function() {
var self = this;
$.populateContent(service,self); -> calls populateContent() ->runSlider() -> **Not proper option.slideDirection always remain same
//$.setSlider(self); -> directly calls runSlider() -> **It is proper** option.slideDirection change
});
});