I have created a custom SharePoint callout with the help of following code.
<script type="text/javascript" src="/_layouts/15/callout.js"></script>
<script type="text/javascript">
ExecuteOrDelayUntilScriptLoaded(getListItems,"callout.js");
function getListItems() {
var Url = "SiteURL/_vti_bin/ListData.svc/AnnouncementList";
var request = new Sys.Net.WebRequest();
request.set_httpVerb("GET");
request.set_url(Url);
request.get_headers()["Accept"] = "application/json";
request.add_completed(onCompletedCallback);
request.invoke();
}
function onCompletedCallback(response, eventArgs) {
var announcements = eval("(" + response.get_responseData() + ")");
var newAnnouncement = document.createElement("div");
for (var i = 0; i < announcements.d.results.length; i++) {
_announTitle = announcements.d.results[i].Title;
_announID = announcements.d.results[i].Id;
_announBody = announcements.d.results[i].Body;
announcementsList.appendChild(newAnnouncement);
var calloutLink = document.createElement("div");
calloutLink.id = _announID;
calloutLink.onmouseover = function () {
curListUrl = this.id;
}
calloutLink.innerHTML = "<div class=\"ms-commandLink\" style=\"text-align: left;font-size: 14px;\"><b>" + _announTitle + "</b><br /><br /></div>";
announcementsList.appendChild(calloutLink);
var listCallout = CalloutManager.createNew({
launchPoint: calloutLink,
beakOrientation: "leftRight",
ID: _announID,
title: _announTitle,
content: "<div class=\"ms-soften\" style=\"margin-top:13px;\">"
+ "<hr/></div>"
+ "<div class=\"callout-section\" style=\"margin-top:13px;\">" + _announBody + "</div>",
});
}
}
</script >
<div id="announcementsList"></div>
You can get this code from here
I am following Display Item Details in a CallOut on Hover Over of Item Title in SharePoint 2013
Here everything works fine, but the callout opens when I click the item, I want it to open when I hover the item.
Any suggestions?
Edit
Updated the code to remove the confusion.
Here I have already used
calloutLink.onmouseover = function () {
curListUrl = this.id;
}
Still it open when I click item.
<div id="showAnnouncementdiv" onmouseover="Javascript:getListItems();">Click Here to Display Announcements</div>?onmouseoverevent . Check this link - w3schools.com/jquery/…