I've got a function that scrolls to an anchor:
function scrollToAnchor(aid) {
var aTag = $("a[name='" + aid + "']");
if (aTag.length) {
$('html,body').animate({
scrollTop: aTag.offset().top - 100
}, 'slow');
aTag.closest('.subpanel').effect("highlight", 5000);
}
}
HTML
<a id="A2" class="gridLabel" name="Add Action Item">
<span id="MainContent_Label19" title="Add / Edit an action item.">Add / Edit Action Item</span>
</a>
I have to call a server side event that performs some sort of action. Once the action is completed I need to call this scrollToAnchor. I tried this:
ScriptManager.RegisterClientScriptBlock(this, GetType(), "OpenActions", "$(function(){
function scrollToAnchor(aid) { var aTag = $('a[name=''' + aid + ''']');if (aTag.length)
{$('html,body').animate({ scrollTop: aTag.offset().top - 100 },
'slow');aTag.closest('.subpanel').effect('highlight', 5000);}} $('#tblAction').show();
scrollToAnchor('Add Action Item');});", true);
However I get errors in the console probably because of my ' ' and " ". Can someone help form this for me.
I also tried:
ScriptManager.RegisterClientScriptBlock(this, GetType(), "OpenActions", "$(function()
{function scrollToAnchor(aid) { var aTag = $('a[name=\"' + aid + '\"]' + ']');if
(aTag.length) {$('html,body').animate({ scrollTop: aTag.offset().top - 100 },
'slow');aTag.closest('.subpanel').effect('highlight', 5000);}} $('#tblAction').show();
scrollToAnchor('Add Action Item');});", true);