Drupal.attachBehaviours के साथ jQuery infinitescroll और jQuery चिनाई - drupal-7, jquery-चिनाई, अनंत-स्क्रॉल

मैं यहां थोड़ा हताश हूं। मैं Drupal.behaviours पर खोजने में सक्षम सब कुछ पढ़ रहा हूं लेकिन जाहिर है कि यह अभी भी पर्याप्त नहीं है। मैं चिनाई के लिए नई छवियों को संलग्न करने के लिए infinitescroll प्लगइन के साथ चिनाई ग्रिड चलाने की कोशिश करता हूं। यह अब तक ठीक काम करता है। अगली बात जो मैं अपनी वेबसाइट पर लागू करना चाहता था, वह एक हॉवर इफेक्ट है (जो छवियों पर जानकारी दिखाता है) और बाद में फैंसीबॉक्स को छवियों को एक हगर्स आकार में दिखाने के लिए।

(function ($) {
Drupal.behaviors.views_fluidgrid = {
attach: function (context) {
$(".views-fluidgrid-wrapper:not(.views-fluidgrid-processed)", context).addClass("views-fluidgrid-processed").each(function () {
// hide items while loading
var $this = $(this).css({opacity: 0}),
id = $(this).attr("id"),
settings = Drupal.settings.viewsFluidGrid[id];

$this.imagesLoaded(function() {
// show items after .imagesLoaded()
$this.animate({opacity: 1});
$this.masonry({
//the masonry settings
});
});

//implement the function of jquery.infinitescroll.min.js
$this.infinitescroll({
//the infinitescroll settings
},

//show new items and attach behaviours in callback
function(newElems) {
var newItems = $(newElems).css({opacity: 0});
$(newItems).imagesLoaded(function() {
$(newItems).animate({opacity: 1});
$this.masonry("appended", newItems);
Drupal.attachBehaviours(newItems);
});
});

});
}
};
})(jQuery);

अब मैं पढ़ता हूं कि मुझे Drupal.behaviours को Reattach करने की आवश्यकता है यदि मैं चाहता हूं कि हॉवर घटना भी नए जोड़े गए सामग्री पर हो।

(function ($) {
Drupal.behaviors.imgOverlay = {
attach: function (context) {
var timeout;
$(".img_gallery").hover(function() {
$this = $(this);
timeout = setTimeout(change_opacity, 500);
}, reset_opacity);

function change_opacity() {
//set opacity to show the desired elements
}

function reset_opacity() {
clearTimeout(timeout);
//reset opacity to 0 on desired elements
}
}
};
})(jQuery)

अब मैं ड्रुपल कहाँ लिखता हूँ।संलग्नक () यह वास्तव में काम करने के लिए? या वहाँ कुछ और त्रुटि मैं सिर्फ एटीएम नहीं देख रहा हूँ? मुझे आशा है कि मैंने प्रश्न लिखा है ताकि इसकी समझ और शायद यह किसी और की मदद भी करे, क्योंकि मैंने अनुभव किया कि ड्रुपल 7 में इस संयोजन का कोई वास्तविक "आधिकारिक" संस्करण नहीं है।

उत्तर:

उत्तर № 1 के लिए 1

ठीक है, समाधान वास्तव में बहुत सरल है। जब इसे सही ढंग से लिखते हैं तो यह भी चलता है। बिल्कुल नहीं Drupal.attachBehaviours() परंतु Drupal.attachBehaviors() । तो यह संयोजन अब काम करता है और मुझे अंततः राहत मिली :)।