Search This Blog

Monday, May 19, 2014

Jquery dilog box depending on today list item

 <div id="pop"></div>

 <link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css">

<script type="text/javascript">
var annclientContext = null;
var annweb = null;
var annmyItems;
var currentQueryString ='<View><Query><Where><Eq><FieldRef Name="Created" /><Value Type="DateTime"><Today /></Value></Eq></Where></Query><RowLimit>1</RowLimit></View>';

var varT = '';
ExecuteOrDelayUntilScriptLoaded(loadAncmntListData, "sp.js");
function loadAncmntListData()
{
annclientContext = new SP.ClientContext.get_current();
annweb = annclientContext.get_web();
var list = annweb.get_lists().getByTitle('Announcements');
var myQuery = new SP.CamlQuery();
myQuery.set_viewXml(currentQueryString);
annmyItems = list.getItems(myQuery);
annclientContext.load(this.annmyItems, 'Include(ID,Title,FileRef)');
annclientContext.executeQueryAsync(Function.createDelegate(this, this.loadAncmntListDataSuccess), Function.createDelegate(this, this.loadAncmntListDataFail));
}
function loadAncmntListDataSuccess(sender, args) {
var itemsEnumerator = this.annmyItems.getEnumerator();
varT = varT +"<div id='dialog' title='Today's Announcement'>";
while (itemsEnumerator.moveNext())
{
// Get current item
var currentItem = itemsEnumerator.get_current();

// Concatenate values
var ide = currentItem.get_item('ID');
varT = varT + "<p><input type='submit' value='View Item' onclick='redirect("+ide+")'/> </p>";
}
varT= varT +"</div>";
  document.getElementById("pop").innerHTML = varT;
$( "#dialog" ).dialog();
}

function redirect(id)
{
window.location ="/Lists/Announcements/DispForm.aspx?ID="+id+"&Source=http://yh1000388lt";
}
function loadAncmntListDataFail(sender, args)
{
alert('loadAncmntListDataFail() failed:' + args.get_message());
}
</script>
<style>
.ui-dialog.ui-widget.ui-widget-content.ui-corner-all.ui-front.ui-draggable.ui-resizable {
    left: 10px !important;
opacity: 0.77 !important;
filter:alpha(opacity=77);
}

.ui-state-default, .ui-widget-content .ui-state-default, .ui-widget-header .ui-state-default {
 
    left: 1px !important;

}
.ui-dialog .ui-dialog-title {
    float: right;
}
</style>

No comments:

Post a Comment