jquery - How to run the JS with on() function with Javascript -
After the JS calendar is fully started, the HTML appears below and I would like to run my JS with
asynchronousViewDefault_CalendarView
code> attributes However, it does not work at all.
Otherwise, is there a solution to my problem, I need to make sure that I use the asynchronousViewDefault_CalendarView attribute to run my JS? HTML: & lt; Div id = "asynchronous viewDefault_CalendarView" & gt; & Lt; div class = "ms-acal-header" & gt; & Lt; Div & gt; & Lt; Table class = "MS-ARM-month" & gt; & Lt; / Table & gt; & Lt; Div class = "ms-acal-vlink" & gt; & Lt; Table & gt; & Lt; Tbody & gt; & Lt; TR & gt; & Lt; Td> & Lt; A href = "javascript: zero (0)" title = "add" evtid = "new_item" & gt; & Lt; Img border = "0" src = "/ _ layout / image / caled .gif" & gt; Add & lt; / A & gt; & Lt; / Td> & Lt; / TR & gt; & Lt; / Tbody & gt; & Lt; / Table & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; / Div & gt; Javascript: $ ("#synchronousViewDefault_CalendarView div div table") .on ("click on", function Hover (function {} {$ (this) .attr ('href', '' ['ab' 'Http: //share/Lists/Calendar.aspx?p=P1');});}); or
$ ("#synchronousViewDefault_CalendarView") .on ("click", '.ms-acal-vlink', function () { Var abc = $ ("# asynchronousViewDefault_CalendarView"). ('A [title = "add"] [evtid = "new_item"]). Hover (function () {$ (this) .attr (' href ',' http: //share/List/Calendar.aspx?p=P1 ');});}); # Asynchronous ViewDefault_CalendarView div div table does not exist To run that selector, there is no element to bind the event handler to on instead, instead you should give it as an ancestor, such as the document < / Code>, or the element that is inserting that HTML: $ (document) .on ("click", "#synchronousViewDefault_CalendarView .ms-acal-vlink", function ( ) {Var abc = $ () "$ [This ()) .attr ('href', 'http: // share)' ([a title = "Add"] [evtid = "new_item"].) / List / calendars.aspx? P = p1 ');});}); In this one Good interpretation is:
Event handlers are only bound to the currently selected elements; they should be present on that page when .on () to make sure that the element Exist and can be selected, for elements present in the HTML markup on the page, the event inside the document handler Make it liable. If the new HTML is being injected into the page, select the elements and add the event handlers after the new HTML is placed in the page. Or, use delegated events to engage an event handler, as described next.
The advantage of the events employed is that they can later process incidents of descending elements added to the document. By selecting an element on which the delegated event handler is enclosed, it is guaranteed to be present at that time, you can use eventual events to avoid the need to attach and remove event handlers often. This element can be a container element of a view in the model-view-controller design, for example, or document if the event handler wants to monitor all the bubbling events in the document. The document element is available in the head of the document before loading any other HTML, so it is safe to attach the event without waiting for the document to be ready.
Comments
Post a Comment