Created
August 8, 2016 10:59
-
-
Save Vannevelj/51c42593158c450c4f6f47dd4ee1cd42 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="col-lg-2 text-center" style="margin-top: 57px;"> | |
@if (Model.ShowPushOptions) | |
{ | |
<div style="display: inline; margin-left: 10px;"> | |
@if (needsAction && !string.IsNullOrWhiteSpace(Model.LeftEntity)) | |
{ | |
<button onclick="handlePush('right')" id="pushToRight" class="btn btn-danger">Push <i class="glyphicon glyphicon-arrow-right"></i></button> | |
<br/> | |
} | |
@if (needsAction && !string.IsNullOrWhiteSpace(Model.RightEntity)) | |
{ | |
<button onclick="handlePush('left')" id="pushToLeft" class="btn btn-danger" style="margin: 5px 0 0 6px"><i class="glyphicon glyphicon-arrow-left"></i> Push</button> | |
} | |
<input asp-for="TargetDatabase" type="hidden" /> | |
<input asp-for="LeftAlias" type="hidden" /> | |
<input asp-for="RightAlias" type="hidden" /> | |
<input asp-for="LeftEntity" type="hidden" /> | |
<input asp-for="RightEntity" type="hidden" /> | |
</div> | |
} | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function handlePush(direction) { | |
console.log(this); | |
console.log($(this)); | |
const enclosingDiv = $(this).parent(); | |
console.log(enclosingDiv); | |
console.log(enclosingDiv.eq(0)); | |
console.log(enclosingDiv[0]); | |
const targetDb = enclosingDiv.find("[name='TargetDatabase']").eq(0); | |
const leftAlias = enclosingDiv.find("[name='LeftAlias']").eq(0); | |
const rightAlias = enclosingDiv.find("[name='RightAlias']").eq(0); | |
const leftEntity = enclosingDiv.find("[name='LeftEntity']").eq(0); | |
const rightEntity = enclosingDiv.find("[name='RightEntity']").eq(0); | |
console.log(targetDb); | |
console.log(leftAlias); | |
console.log(rightAlias); | |
console.log(leftEntity); | |
console.log(rightEntity); | |
const options = { | |
url: '/Comparison/Push', | |
type: 'post', | |
data: { | |
'PushFromLeftToRight': direction === 'right', | |
'PushFromRightToLeft': direction === 'left', | |
'TargetDatabase': targetDb.val(), | |
'LeftAlias': leftAlias.val(), | |
'RightAlias': rightAlias.val(), | |
'LeftEntity': leftEntity.val(), | |
'RightEntity': rightEntity.val() | |
} | |
}; | |
console.log(options); | |
$.ajax(options) | |
.done(function(data) { | |
console.log('received response!'); | |
console.log(data); | |
}); | |
return false; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment