What is the best way to get an element’s tag name in JS?

nodeName is the most consistent here. I would suggest you take a minute and read this post for a few differences and inconsistencies with tagName if you’re more curious as to why. For the prototype part of the question…it’s a JavaScript property, just this.nodeName should work or element.nodeName, whatever your element’s called in the current … Read more

How do I select an option using prototype

var options = $$(‘select#mySelect option’); var len = options.length; for (var i = 0; i < len; i++) { console.log(‘Option text=” + options[i].text); console.log(“Option value=” + options[i].value); } options is an array of all option elements in #mySelect dropdown. If you want to mark one or more of them as selected just use selected property … Read more

Using JQuery and Prototype in the same page

Currently you can do something like this: <head> <script type=”text/javascript” src=”https://stackoverflow.com/obp/js/prototype.js”></script> <script type=”text/javascript” src=”https://stackoverflow.com/obp/js/jquery.js”></script> <script type=”text/javascript”> var $j = jQuery.noConflict(); </script> </head> Then, use jQuery as $j() and Prototype’s $().

How to have a mouseover event fire only if the mouse is hovered over an element for at least 1 second?

You can’t delay the firing of the event, but you can delay your handling of the event. Here’s a quick example without jQuery or Prototype that will make it easier to understand. var delay = function (elem, callback) { var timeout = null; elem.onmouseover = function() { // Set timeout to be a timer which … Read more

Ways to add javascript files dynamically in a page

To load a .js or .css file dynamically, in a nutshell, it means using DOM methods to first create a swanky new “SCRIPT” or “LINK” element, assign it the appropriate attributes, and finally, use element.appendChild() to add the element to the desired location within the document tree. It sounds a lot more fancy than it … Read more

How to return AJAX response Text? [duplicate]

remember that onComplete is called long after the someFunction is done working. What you need to do is pass a callback function to the somefunction as a parameter. This function will be called when the process is done working (ie, onComplete): somefunction: function(callback){ var result = “”; myAjax = new Ajax.Request(postUrl, { method: ‘post’, postBody: … Read more

Twitter Bootstrap 3 dropdown menu disappears when used with prototype.js

I’ve also used code from here: http://kk-medienreich.at/techblog/magento-bootstrap-integration-mit-prototype-framework but without a need to modify any source. Just put code below somewhere after prototype and jquery includes: (function() { var isBootstrapEvent = false; if (window.jQuery) { var all = jQuery(‘*’); jQuery.each([‘hide.bs.dropdown’, ‘hide.bs.collapse’, ‘hide.bs.modal’, ‘hide.bs.tooltip’, ‘hide.bs.popover’, ‘hide.bs.tab’], function(index, eventName) { all.on(eventName, function( event ) { isBootstrapEvent = true; … Read more

Trigger an event with Prototype

event.simulate.js fits your needs. I’ve used this several times and it works like a charm. It allows you to manually trigger native events, such as click or hover like so: $(‘foo’).simulate(‘click’); The great thing about this is that all attached event handlers will still be executed, just as if you would have clicked the element … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)