I read the documentation on the noconflicts() to mean that Prototype should be loaded first and then:
<script
This all worked great in all browsers except in IE8 which had no clue what jQuery() meant. IE8 says jQuery is undefined.
So I reversed the order of loading, jQuery first then Prototype, and now everybody is happy. Did I just read the documentation wrong or is there something else here I should be worried about?
According to ECMAScript, the root of the prototype chain is Object.Prototype. Each object has an internal property [[Prototype]] that could be another object or NULL.... However, it also says that every function has the Function prototype object: Function.Prototype, it confused me, because a function is an object, for a function object, what is its function prototype and object prototype..For example:
var x = function (n) {return n+1;};
what is the relationships of x, Object.Prototype and Function.Prototype
I am trying to get to the bottom of javascript object, prototypes etc. I have a fairly good grasp of it, but I get confused the closer I get to the base object.prototype. FIrst of all, I was under the impression that all objects descend directly from Object. But some objects (like Array) seem to inherit properties and methods from the function.prototype. So does this mean that the chain is like this:
object -- function -- array Second, I noticed (on the mozilla javascript reference site that object.prototype inherits properties and methods from function.prototype and vice versa!? How can this be? I must be missing something important about understanding the chain?
I want ask you if, for a web portal/application, is better prototype or Jquery? I don't want to innesc some type of flame, but after the announce that drupal use JQuery and that the new Wordpress 2.2 use Jquery I ask myself if my choice of use prototype.js is the bettere choice.
QUESTION ONE: When is use of the jQuery prototype object appropriate, and when is it not?
BACKGROUND:I am still trying very hard to identify the error that is prohibiting me from incorporating a jQuery plug-in into my site in a manner similar to the way that the author of the plug-in has incorporated it into his.Although I have sought consultation with the author, he appears uninterested in working with me.My still fledgling knowledge of jQuery tells me that the author of the plug-in and my implementation of his plug-in are constructed differently.Whereas I use jQuery's prototype property to reference my method and then assign my method anonymously to my HTML document as follows: $().myJQMethod().The author of the plug-in does something very different.I have extracted from the author's plug-in and my implementation of it. Links to the source pages have been included.
CONSTRUCT A (The jQ_Impromptu Plug-In): (function($) { $.prompt = function(message, options) { })(jQuery);[code]...
QUESTION TWO: Although I am able to implement the author's method, it is not performing as it should. When the alert box appears with focus the hosting HTML page is suppose to show through with dimmed opacity.My implementation does not achieve this effect. Firebug has alerted to me to the following breakpoint, but I am poorly unable to interpret it.
I've previously written an image carousel with lightbox and to be honest forgot about it for quite a long time. I've just been tasked with making a few modifications (I wrote this code about 6 months ago)
Now, the problem I have is that I now need to call the internal method from the ligthbox plugin.
I've tried setting a reference to this like this but it just won't play ball. I can see that the ajax feed gets called but unfortunately I can't then access it.
I have developed a widget. I am using the jquery core api. Im having a problem when the widget is used in a weebly site. I know weebly uses prototype and I am using the workaround:
var $j = jQuery.noConflict(); however there is still a clash of some sort. I think every prototype.js function is being called or something because the page is taking a long long time to load as there are many requests being made which look like this:
So for a research topic at school, I chose to do web development software trends, to see if there are any general commonalities. One sub-topic I chose to do was Javascript, and where it seems to be heading. After reading a bit about it (I'm very new to web development), I learned that jQuery and Prototype seemed to be the most popular options when using javascript, but I didn't understand why they are compared against each other so often. If jQuery is a library, and Prototype is a framework, why would people only choose one or the other? I know some people use both, and I also realize that there's minor conflicting syntax issues, but I was hoping someone with more experience could help me understand why a framework and a library can be compared head to head.
I have been trying in vain for many days to resolve a conflict between javascript libraries. My homepage uses jquery horizontal css menubar + a combined mootool and prototype accordian type sliding information box in the middle of the webpage. I find that the highlighter of the css menubar does not work when prototype.js is also loaded on the same page. I have read somewhere that $ should be replaced however I have tried every possible option and none works. I have jquery loading first as it is on my template, with this: <script type='text/javascript' src='../Web/Templates/jquery-1.3.2.js'></script> <script type='text/javascript' src='js/example.js'></script>
And my mootool and prototype loades further below like this: <script type="text/javascript" src="scripts/intro/prototype.lite.js"></script> <script type="text/javascript" src="scripts/intro/moo.fx.js"></script> <script type="text/javascript" src="scripts/intro/moo.fx.pack.js"></script> <script type="text/javascript"> function init(){ var stretchers = document.getElementsByClassName('box'); var toggles = document.getElementsByClassName('tab'); var myAccordion = new fx.Accordion( toggles, stretchers, {opacity: false, height: true, duration: 600} ); //hash functions var found = false; toggles.each(function(h3, i){ var div = Element.find(h3, 'nextSibling'); if (window.location.href.indexOf(h3.title) > 0) { myAccordion.showThisHideOpen(div); found = true; } }); if (!found) myAccordion.showThisHideOpen(stretchers[0]); } </script>
I need to know how to add an event to a button. The specific issue is that I want to add an event which is a prototype function of a class. Consider the following as an example:
I want to write a plugin, say 'myPlugin' which I can use like Code: $('#myID').myPlugin() ; $('#myID').myPlugin.test() ;
The plugin I wrote looks like Code: (function($){ $.fn.myPlugin = function() { // do something } $.fn.myPlugin.test = function() { var $this = $(this) ; // do something ; }})(jQuery) ;
This works and it doesn't work. It works because test() is called, but this is not the element with id '#myID' it is $.fn.myPlugin. To fix this I tried the following Code: (function($){ $.fn.myPlugin = function() { // do something } $.fn.myPlugin.prototype.test = function() { var $this = $(this) ; // do something ; }})(jQuery) ; but now the function 'test' is unknown.
I tried load method super as smartupdater orPeriodicalUpdater (Prototype). Now the problem is that I have to build a cycle (loop) and each time I have to change the time (that I take from database) so how method (function) can I use to load external code (example load()) modifying continuosly the timeout?
One of the complaints about prototype.js (google for it if you're not familiar with it) is that it's poorly documented. I have this inkling that the key to understanding prototype.js is in the bind function.
The problem with Javascript is that the "this" operator is poorly overloaded and it is often hard to understand in the context of object-oriented javascript
As I read this, it states that all functions (which are themselves objects) will, in the future, have an associated method called "bind". The function() function, so to speak, simply instantiates a Function object with the parameter list and then evals the statement, sticking the resulting execution-tree in the current code frame.
The "this" there refers to the function object associated with the call to bind(), right? But the word "arguments" there refers to the arguments passed to the function object *generated by* the call to bind().
In every example within prototype.js, bind() is called either in a constructor or within a method contexted to a javascript object, and is always called with "this" as its argument, e.g.:
As I read the code it seems to be stating that the "this" object referred to within bind()'d functions are being coerced into always referring to the current instantiated object.
But isn't this always the case anyway? Is this a rather confusing attempt to ensure "this" purity whereby the call
method.apply(object, arguments)
is forced to always have the reference to the containing object present?
I think I've got it. Bind() generates uniq functions that contain live references to the objects to which they belong, such that the function object can then be passed to setTimeout() or onMouseOver(), handlers that accept functions but not objects.
Is there anyway to 'restore' the original alert() method or is it gone forever?
I know you can do window.alert = Window.prototype.alert, but lets say you also set Window.prototype.alert = function() { } or lets say we're in Opera, which doesnt have a Window "class".
I wanted to add an object as a prototype to separate my methods more nicely, however, I ran into a couple of problems. Apart from the obvious "scope" issues I found that any instances of my class shared the objects methods and properties.
I realise (now) that this is actually how prototypes work, they share functions and objects rather than create new instances of them for every "class", but is there any way around it? (or shouldn't I be doing things like this at all?) Code:
I am working on my own pop up calendar, mainly because the one I am currently using crashes the Safari browser at times.
So, I want to verify that what I am doing will work, in that I want to be able to have multiple calendars open at the same time, each independent of the other.
So, I start it off with:
var Calendar = { dateSelected: null, topPos:null, leftPos:null,
somefunction:function(e) { ... } };
If I create more than one calendar object, will they have their own variables, in that the dateSelected, topPos and leftPos will be unique to that instance?
Or, is there a better way to do this, that is cross-platform.....
In my research in the javascript language I have encountered problems with implementing prototype inheritance while preserving private methods functioning properly. Here is an example: Code:
I have <div id ="changeable"> with some html in it. I have a link that calls the function to replace the info in the div. The problem is that the "creative_development.inc" file is added to the top of the div and does not replace the content. How do I replace the content, and not just add content?
First, about the environment: - The web pages automatically generated. - Pages can be inserted to each other - When a subpage to be inserted is being generated, it does not know will it be inserted or not. - That because each subpage uses the <script src=...> tags to load the script it needs. - in the external script files I'm trying to protect it from repeated execution checking (if(){}) the value of a variable which is created after in the script.
Everything worked fine until I tried to use the .prototype to declare the method of my objects.
In the Internet Explorer, I got "Object does not support this property or method", on the access to a prototype function, because the prototype of my object was deleted by itself after the second load of the external script. Code: