Class Instance From String
Mar 17, 2007I have a String instance which contains the name of a class. Is there some way I can instantiate that class from given the class name in the string?
View 4 RepliesI have a String instance which contains the name of a class. Is there some way I can instantiate that class from given the class name in the string?
View 4 RepliesI have a javascript object which dynamically generates a table adding, deleting and moving rows as the user clicks on buttons or links. Problem is when I generate a table row and add the javascript method call to my class, I have to put the object instance name variable of the class in order for it to be called from the onclick=function(). This is seriously limiting, but I'm stuck for a way round it. Heres a edited of the code so you get the idea....
Instantiating the object :-
var dtl = new DynamicTableList("table1", $
{myObject.allFieldsAsJavaScriptArray}, true, true, true);
My javascript class DynamicTableList, note the dtl javascript object
instance variable being referred to in the addRow function. How can I
avoid this???
function DynamicTableList(thisObjName, tableName, options, showDelete,
showUp, showDown)
{
this.processRow = function(r, row, up, down)
{
...
};
this.processRows = function()
{
...
};
this.getVisibility = function(visible)
{
...
};
this.delRow = function(button)
{
...
};
this.addRow = function(selection)
{
...
if (showDelete)
{
var cell2 = document.createElement('TD');
var inp2 = document.createElement('IMG');
/
************************************************** ***********************************************/
inp2.onclick=function(){dtl.delRow(this);} // Have to specify
dtc!!!!!!!!
/
************************************************** ***********************************************/
inp2.title='Delete'
inp2.alt='Delete'
inp2.src='images/delete.gif'
cell2.appendChild(inp2);
row.appendChild(cell2);
}
...
tbody.appendChild(row);
this.processRows();
};
this.moveRow = function(node, vector)
{
};
}
Obviously the code dtl.delRow(this); is being dynamically generated, but how do I replace the dtl instance name with something that'll work whatever the user of this class calls the instance of it!
I need to change the background-image (or possibly background-position) property of each new instance of a div with a particular class. I will have a set of images to choose from, or could create a sprite with all of the images.
Example:
Code:
<div class="desc">content</div> **needs background-image: url(pic1.jpg)
<div class="desc">content</div> **needs background-image: url(pic2.jpg)
...
etc.
The page code is dynamically generated from our CMS, so can't change the HTML.
Basically I have this code:
Code:
<div id="rightNews">
<div class="showHead">
<a href="#" class="showAcc">7th July 2010</a><br />
Lorium epsom diem Lorium epsom diem Lorium epsom diem
[Code]....
But when I click to expand one coloumn all of them expand as they have the same class, is there a way so the others close when another one is clicked?
I have the following style markup:
<h2>
<span class="status">
UNDER OFFER
</span>
[Code].....
As i'm trying to add an overlay image to the hyperlink so it will appear on top of the image that is already there (css absolute and z-index).
I have a large number of "li"s with the same class - i.e;
<li class="month01Days"></li>
:
:
[code]....
Is it possible to create a function that will find a class name or id name and then assign that name as variable string?
For example, my body has a class name:
<body class="Sunday">
I need to have a function (using jquery or just regular javascript) that will determine that class name and then assign it to a variable named bodyClass, so that bodyClass="Sunday".
Is there a quick jQuery one liner to return (as an array) all class names that start with "{insert_string_here}"The equivalent of the following:
Code:
var response = $( "*[class^='arete']");
var myClassArray = [];
for( var ix=0; ix < response.length; ix++)
[code]....
I have a few String prototypes such as String.prototype.EscapeReg = function () { return this.replace(/[-[]{}()*+?.,\^$|#s]/g, "\$&"); }; // Escapes characters for use with a regular expressionI also have my own class/ library which is used like this var adg = new AndyG_ns.ADG_Utils(); adg.StartClock('AndyClock','dd mmm yy hh:nn'); // etc.What I would like to do is to only add the prototype to my library (not to the global namespace). The end result I'm looking for is to use code such as:
var adg = new AndyG_ns.ADG_Utils();
var myString = new adg.AString();
var parsed = myString.EscapeReg();
In addition, I want to be able to also use/create my special string sub-class within my library. I suppose I'm saying that I would like to extend or super-class the native String object.
These 2 lines caused an error in IE5. The error is "Function expected". Why?
var d=new Date();
document.write(d instanceof Object + "<br>");
I have some links that open a window, when this window is open various php processes are carried out and it sets serveral global variables. The problem i am having is users, you can't just tell them to have one instance of the window open you have to enfore that rule and i am having a problem doing that.
i have this code:
function launch(newURL, newName, newFeatures, orgName) {
var remote = open(newURL, newName, newFeatures);
if (remote.opener == null)
remote.opener = window;
remote.opener.name = orgName;
return remote;
}
and this function is called upon by another function Code:
I've been searching and playing with this script for the past few hours and finally got it work!
Code:
<script type="text/javascript">
function fnSelect(objId)
{
fnDeSelect();
[Code]......
I'm trying to use a variable that is passed into a function to to dynamically name an instance of an Object(). I've created a Timer() Object that seems to work just fine... the problem is I can't figure out how to pass in an instance name into setTimer() to create a new instance of Timer() object?? My ultimate goal is to have multiple instances of the Timer() Object running at once. While the code below works it only allows me to create 1 instance of the Timer() Object with the name of tmp. Code:
View 8 Replies View RelatedI am new to Javascript and am working with Ajax. I am building a content manager for my site, and I have an instance of CKEditor. I was wondering what the javascript would be to get the value of the textarea. Normally with a textarea I use formname.elementname.value. When I use that with the CKEditor I get a null value.
View 1 Replies View RelatedI have a script like below
Code:
<script type="text/javascript">
var monthtext=['January','February','March','April','May','June','July','August','September','October','November','December'];
[Code]...
Only the second calendar is taking effect. All the dropdowns in calendar1 is empty. Please help me.
My code: [URL]... When I click on UpraviƄ in class edit I need add some HTML code to begin and to end of class entry how to I can select class entry in the same class post on which I clicked?
View 1 Replies View RelatedI have the following code running in FireFox 1.5 (a remote XUL
application):
var req = new XMLHttpRequest();
// execution will block until request is
completed
// third param set to false makes request
synchronous
req.open(strMethod, uriTarget, false);
if(strMethod == "POST") {
req.setRequestHeader('Content-Type','application/x-www-form-urlencoded;
charset=UTF-8');
}
req.onreadystatechange = function () {
if (req.readyState == 4) {
if(req.status == 200) {
strResult = req.responseText;
xmlResult = req.responseXML;
}
else {
strLastError = uriTarget + " returned http error code " +
req.status + "
" + req.statusText;
if(intVerbosity > 1) throw new Error(strLastError);
}
}
}
req.onerror = function() {
strLastError = uriTarget + " fetch failed while " +
arrReadyState[req.readyState];
if(intVerbosity > 1) throw new Error(strLastError);
}
req.send(strRequest);
By the time it gets to req.send() (at the bottom) all the callback
functions like req.onerror still have values of null. I've verified
this using the Venkman debugger with req as a watch variable.
the code is clearly assigning functions to those callback function
objects. Any idea why they are all turning up null?
I have a client, let's call them "BuyNow." They would like for every instance of their name throughout the copy of their site to be stylized like "BuyNow," where the second half of their name is in bold.
I'd really hate to spend a day adding <strong> tags to all the copy. Is there a good way to do this using jQuery?
I was looking in the firebug debugger and noticed that my main .js file was somehow being called twice, but I don't see where. There are dozens of files involved in this particular problem, so I think the best way to go about solving it is to test - in run time - if my js file is already in place on the page, do nothing - otherwise call it. This is pseudo that I have monkeying around with but it's not working.
Code:
function checkFile() {
var fileExist = new fileExist();
fileExist.onLoad = isPresent;
[code]....
I thought this would work, perhaps it's because of an argument I need to pass in to checkFile(ZYX) but not sure.
I am wanting to add a style (bold and blue for example) to every instance of a word or words on my website. Is this possible with jQuery? And how would I write it?
View 1 Replies View RelatedI have a page that loops through a db and places stories inside divs. I need to hide the first and second instances of those divs. Hiding the first one isn't a problem using display="none". The problem I'm having is how do I find and hide the second instance?
View 2 Replies View RelatedI have found a great bit of javascript that I want to use on my site but I want to use it three times on the same page. If you look at [URL] you see three pictures at the bottom I want to make them change but the first only has four images the second has five and the third has three so I want to use the same code below on them all separatly.
Code:
<script type="text/javascript">
// Flexible Image Slideshow- By JavaScriptKit [URL]
// For this and over 400+ free scripts, visit JavaScript Kit-[URL]
// This notice must stay intact for use
var ultimateshow=new Array()
//ultimateshow[x]=["path to image", "OPTIONAL link for image", "OPTIONAL link target"]
ultimateshow[0]=['images/rotate/tattoos/main-tattoo1.jpg', '', '']
ultimateshow[1]=['images/rotate/tattoos/main-tattoo2.jpg', '', '']
ultimateshow[2]=['images/rotate/tattoos/main-tattoo3.jpg', '', '']
//configure the below 3 variables to set the dimension/background color of the slideshow .....
I've been working on a site that uses some JS to rotate some images near the top - the nice looking ones of the safari lodge :Which uses the code :
Code:
<script type="text/javascript">
//new fadeshow(IMAGES_ARRAY_NAME, slideshow_width, slideshow_height, borderwidth, delay,
[code]....
Is there a way to reinitialize a variable in a function without having to add another instance?
View 1 Replies View RelatedI'm using easySlider and masonry but I'm having problems in using multiple instances of easySlider. What I'm trying to do is to remove the first instance of easySlider and then create a new instance that has new set of images.[URL].. But it doesn't seem to work correctly. When you click box#1 (CM Partners) the slider works great. But when you click on box#3 (NBCM), the slider doesn't work and notice that it adds a 'Previous' link even though it's the first frame/slide. Also, the slider doesn't work.
[Code]...
I have made/modifying a script that I can create AJAX objects on the fly. It is working fine in Chrome, FF, Opera, Safari but not IE -.- IE = nightmare
[Code]...