Posts

Showing posts with the label javascript-events

Telerik MVC controls, OnDocumentReady is firing twice

Telerik MVC controls, OnDocumentReady is firing twice I'm new to Telerik MVC controls, so this may be something simple. I started out with making a new TelerikMvcApplication solution. Site.Master: </div> <%: Html.Telerik().ScriptRegistrar().DefaultGroup(group => group.Combined(true).Compress(true).Add("Index.js")) %> </body> </html> Index.aspx: <%: Html.Telerik().ScriptRegistrar().OnDocumentReady("Index.Init()") %> </asp:Content> Index.js: var Index = function () { return { Init: function () { alert('1'); } }; } (); When I load Index.aspx, the Init() function in Index.js is fired twice, so I see 2 alerts one after another. If I assign a click handler to a button inside the Init() function and hit the button with FireBug, it is actually showing 2 events being assigned to the button. Why is this happening? After some more firebugging, I figured out that both ...

How can I trigger a JavaScript event click

How can I trigger a JavaScript event click I have a hyperlink in my page. I am trying to automate a number of clicks on the hyperlink for testing purposes. Is there any way you can simulate 50 clicks on the hyperlink using JavaScript? <a href="#" target="_blank" onclick="javascript:Test("Test");">MSDN</a> I'm looking for onClick event trigger from the JavaScript. 8 Answers 8 Performing a single click on an HTML element: Simply do element.click() . Most major browsers support this. element.click() To repeat the click more than once: Add an ID to the element to uniquely select it: <a href="#" target="_blank" id="my-link" onclick="javascript:Test('Test');">Google Chrome</a> and call the .click() method in your JavaScript code via a for loop: .click() var link = document.getElementById(...