This is a migrated thread and some comments may be shown as answers.

Error: .attachEvent is not a function

1 Answer 311 Views
ToolBar
This is a migrated thread and some comments may be shown as answers.
tom
Top achievements
Rank 1
tom asked on 06 Nov 2008, 07:33 PM
I have a delete button on my toolbar that I need a popup before deleting.

So, I need the delete button on the toolbar to confirm the user really wants to.

I've followed the instructions below:
http://www.telerik.com/help/aspnet/toolbar/tool_stop_postback.html

I get the following error in my Firefox error console:  "....attachEvent is not a function"

Here is my radtoolbar:
<telerik:RadToolBar ID="UserAccessEditToolBar" runat="server"/> 
 
and here is my javascript:
<script type="text/javascript"
 
<%= UserAccessEditToolBar.ClientID %>.attachEvent("OnClientClick","click_handler"); 
 
function click_handler(sender, e) 
   if (sender.CommandName == "clientside") 
   { 
       // call clientside function here 
       return false; 
   } 
 
</script> 
any suggestions?



1 Answer, 1 is accepted

Sort by
0
tom
Top achievements
Rank 1
answered on 06 Nov 2008, 08:23 PM
Resolved
we found this article:
http://www.telerik.com/support/kb/aspnet-ajax/window/using-radprompt-and-radconfirm-with-telerik-navigational-controls.aspx

which gave us the javascript below




<script type="text/javascript">   
        var lastClickedItem = null;      
        var clickCalledAfterRadprompt = false;   
        var clickCalledAfterRadconfirm = false;   
        function toolbarClicked(sender, args)   
        {   
            if (args.get_item().get_text() == "Delete")   
            {   
                if (!clickCalledAfterRadconfirm)   
                {   
                    args.set_cancel(true);   
                    lastClickedItem = args.get_item();               
                    radconfirm("Are you sure you want to postback?", confirmCallbackFunction);   
                 }   
            }   
               
        }   
         function confirmCallbackFunction(args)   
        {                 
            if (args)   
            {     
                clickCalledAfterRadconfirm = true;   
                lastClickedItem.click();   
            }   
            else  
            clickCalledAfterRadconfirm = false;            
            lastClickedItem = null;   
        }   
        </script>   

then this was our toolbar line:
    <telerik:RadToolBar ID="UserAccessEditToolBar" runat="server" AutoPostBack="true" OnButtonClick="UserAccessEditToolBar_ButtonClick" OnClientButtonClicking="toolbarClicked" /> 
 

OnClientButtonClicking fires the javascript and the confirmation box.

If the user hits OK and wants to delete the item, then the "OnButtonClick" is fired and actually deletes the record.
Tags
ToolBar
Asked by
tom
Top achievements
Rank 1
Answers by
tom
Top achievements
Rank 1
Share this question
or