मेरी वास्तविक समस्या यह है कि .live() jQuery विधि काम नहीं कर रही है। मैं .live विधि का इस्तेमाल कियाjQuery .live() काम नहीं कर रहा
<script type="text/javascript" src="ui/js/jquery-1.4.2.js"></script>
<script type="text/javascript" src="ui/js/jquery-ui-1.8.1.custom.min.js"></script>
<script type="text/javascript" src="ui/js/color.js"></script>
<script type="text/javascript" src="engine/js/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript" src="ui/js/ui.js"></script>
<script type="text/javascript">
// UI effects
$(document).ready(function()
{
$('button').sb_animateButton();
$('input').sb_animateInput();
$('.top_menu_item').sb_animateMenuItem();
$('.top_menu_item_right').sb_animateMenuItem();
$('.left_menu_item').sb_animateMenuItem();
});
</script>
के बाद से मेरी साइट AJAX अनुरोध का उपयोग करता है:
jQuery.fn.sb_animateMenuItem = function()
{
var mousehoverColor = '#0089F7';
var duration = 250;
return this.each(function()
{
var originalColor = $(this).css('background-color');
$(this).live('mouseover', function()
{
this.style.cursor = 'pointer';
$(this).animate().stop();
$(this).animate(
{
backgroundColor: mousehoverColor
}, duration);
});
$(this).live('mouseout', function()
{
this.style.cursor = 'default';
$(this).animate(
{
backgroundColor: originalColor
}, duration);
});
});
};
यह Snipped इस तरह से मैं एक और पेज प्रयोग किया जाता है:
इस कोड को जहां मैं इसका इस्तेमाल सी पहले स्निपेट में, लेकिन जब मैं पृष्ठ लोड करता हूं तो प्रभाव बटन/इनपुट ... टैग लागू नहीं होते हैं।
तो मैं .live विधि निकालकर 'सामान्य' तरीके से उपयोग, ui पहले Snipped में परिभाषित प्रभाव से लागू होते हैं लेकिन केवल तत्व किसी भी AJAX अनुरोध से पहले भरी हुई। AJAX अनुरोध के बाद लोड किए गए तत्व पहले स्निपेट से प्रभावित नहीं होते हैं (हालांकि उनके पास एक ही चयनकर्ता है)।
मदद के लिए धन्यवाद।
एक तरह वास्तव में बड़ी +1। इस उत्तर से बहुत कुछ सीख लिया। सवाल पूछने के लिए ओपी को भी +1। – user113716
अच्छा ... मैंने दोनों तरीकों की कोशिश की, लेकिन यह काम नहीं कर रहा है। मैंने किसी अन्य तरीके से समस्या का सामना करने का निर्णय लिया: http://stackoverflow.com/questions/3032767/insert-html-into-a-page-with-ajax। – siannone
@ सिल्वियो - क्या काम नहीं कर रहा है? मैंने एक डेमो प्रदान किया जो दिखाता है कि यह काम करता है, आपको समझा जाना चाहिए * क्या * काम नहीं कर रहा है। जब आप समस्या को नहीं जानते हैं तो समाधान देना मुश्किल है ... –