2013-04-30 44 views
0

我有這個小腳本,它允許我在用戶在日曆中的某個日期使用鼠標時顯示條目。 我想改變這種以功能的onclick設置,但我不知道如何做到這一點:如何在jQuery中使用onclick更改mouseenter

這是代碼的一部分:

// Customisation Variables 
       /** The CSS class which will be assigned to the Event Calendar */ 
       calendarClass: 'hasEventCalendar', 
       /** The CSS class which will be assigned to day when the day contains a entry */ 
       dayEventClass: 'ui-state-active hasEvent', 
       /** The standard options to send to the datepicker */ 
       datepickerOptions: { 
        firstDay: 1 /* Monday */ 
       }, 
       /** Whether or not to disable the datepicker date selection click */ 
       disableClick: true, 
       /** 
       * The domEvents option contains all the events which you would like to assign to a $day 
       * 
       * It will send the following arguments back to you: 
       * - domEvent 
       * - details 
       * 
       * The details of the details argument contains the following: 
       * - {Number} year 
       * - {Number} month 
       * - {Number} day 
       * - {String} date 
       * - {Array} dayEntries 
       * - {Array} monthEntries 
       * - {Element} datepicker 
       */ 
       domEvents: { 
        mouseenter: function(domEvent, details) { 
         // Prepare 
         var $day = $(this), 
          dayEntries = details.dayEntries; 
         // Output 
         $.each(dayEntries,function(i,entry){ 
          $eventsInfo.append(
           '<p>'+ 
            '<strong>'+entry.title+'</strong> <br/>'+ 
            '<em>'+entry.start.toLocaleDateString()+'</em>'+ 
            '<br>'+entry.text+''+ 
           '</p>' 
          ); 
         }); 
        }, 
        mouseleave: function(domEvent, details) { 
         // Clear 
         $eventsInfo.empty(); 
        } 
       } 

如何修改呢?

回答

0

變化domEventsmouseenter屬性onclick,像這樣:

// Customisation Variables 
       /** The CSS class which will be assigned to the Event Calendar */ 
       calendarClass: 'hasEventCalendar', 
       /** The CSS class which will be assigned to day when the day contains a entry */ 
       dayEventClass: 'ui-state-active hasEvent', 
       /** The standard options to send to the datepicker */ 
       datepickerOptions: { 
        firstDay: 1 /* Monday */ 
       }, 
       /** Whether or not to disable the datepicker date selection click */ 
       disableClick: true, 
       /** 
       * The domEvents option contains all the events which you would like to assign to a $day 
       * 
       * It will send the following arguments back to you: 
       * - domEvent 
       * - details 
       * 
       * The details of the details argument contains the following: 
       * - {Number} year 
       * - {Number} month 
       * - {Number} day 
       * - {String} date 
       * - {Array} dayEntries 
       * - {Array} monthEntries 
       * - {Element} datepicker 
       */ 
       domEvents: { 
        onclick: function(domEvent, details) { 
         // Prepare 
         var $day = $(this), 
          dayEntries = details.dayEntries; 
         // Output 
         $.each(dayEntries,function(i,entry){ 
          $eventsInfo.append(
           '<p>'+ 
            '<strong>'+entry.title+'</strong> <br/>'+ 
            '<em>'+entry.start.toLocaleDateString()+'</em>'+ 
            '<br>'+entry.text+''+ 
           '</p>' 
          ); 
         }); 
        }, 
        mouseleave: function(domEvent, details) { 
         // Clear 
         $eventsInfo.empty(); 
        } 
       } 
+0

它doen't工作,沒什麼澳鵬 – 2013-04-30 16:05:04

+0

這意味着你有你的腳本等問題。我提供的代碼應該可以工作。 – RouteMapper 2013-04-30 19:04:22