|
jQuery still chokes on it. Is there a difference between instance and this?
|
|
|
|
|
"this" is a keyword. "instance" is just what I named that variable. You could rename "instance" to "donkey" and it would act the same. What my changes are supposed to do are capture the value returned from "this" and store it in the "instance" variable so you can use it in nested functions where "this" changes. I'm not sure why it still chokes. Try replacing the line that chokes with alert("test") .
Martin Fowler wrote: Any fool can write code that a computer can understand. Good programmers write code that humans can understand.
|
|
|
|
|
Whoops!
I completely missed that part. I thought instance was some JavaScript keyword I didn't know about (it's been a long time since I last did any significant JavaScript). Just tried it and it seems to work now. Copying this to a local variable solves the problem.
Thank you very much. I've been banging my head on my desk all morning.
|
|
|
|
|
In addition to what Graham said, you don't need to put prototype functions in the constructor. You can do this instead:
function MyClass() {
this.OnTimerStart = function() {
alert("started");
};
}
MyClass.prototype.StartTimer = function() {
if (this.OnTimerStart) {
this.OnTimerStart();
}
}
var instance = new MyClass();
instance.StartTimer();
Martin Fowler wrote: Any fool can write code that a computer can understand. Good programmers write code that humans can understand.
|
|
|
|
|
Is there a reason for doing it that way versus what I was doing? I can't help my strong desire to wrap a "class" in curly brackets (i.e. the C# way) which I think was why I naturally did it that way.
|
|
|
|
|
Your way, the function would be created each time the class constructor is called. My way, it is created once. Doing it your way would be in C# like creating a delegate rather than a function and reassigning the delegate each time the constructor is called. Basically, it's an unnecessary performance hit.
Martin Fowler wrote: Any fool can write code that a computer can understand. Good programmers write code that humans can understand.
|
|
|
|
|
|
Hi,
I have a jquery dialog which loads another aspx page inside iframe.
I want dialog to resize as per the contents inside Iframe.
Tried setting
width:'auto' and autoResize: true
in the dialog constructor but no luck.
modified on Wednesday, August 24, 2011 9:25 AM
|
|
|
|
|
You will have to create some javascript yourself to build this. First you will have to attach an event to the onload of the iframe. In that onload function you will have to try to calculate the height of the contents and resize the jQuery dialog window. I built something similar a couple of months back, but it didn't work equally well in all scenario's.
var popup_div = document.createElement('div');
var popup_content = document.createElement('iframe');
var dialog = null;
jQuery(popup_content).css({ 'width': '100%', 'height': '100%', 'border': 'none', 'visibility': 'hidden' });
popup_content.src = url;
popup_content.name = name;
popup_div.id = 'bb-dialog';
popup_div.appendChild(popup_content);
document.body.appendChild(popup_div);
jQuery(popup_content).bind('load', function () {
height = height == 'auto' ? jQuery(top.window.frames[name]).height() : height,
width = width == 'auto' ? jQuery(top.window.frames[name]).width() : width;
jQuery(popup_div).dialog({
show: 'fade',
hide: 'fade',
title: title,
modal: true,
position: 'center',
width: width,
height: height,
closeOnEscape: false,
close: function () { this.parentNode.parentNode.removeChild(this.parentNode); },
open: function () { jQuery(popup_content).css('visibility', 'visible'); },
buttons: button_set
});
jQuery(this).unbind('load');
});
Try it out and see if it works for you. Though you might have to tweak it a little bit.
|
|
|
|
|
I found and adapted an HTML script as shown below. It fits my needs perfectly. However, I don't know how to store the field-values of repeated lines in a javascript array that subsequently passes its contents on to a PHP-array that enables me to store the date in a MYSQL-database. I tried to fix something myself in de 3rd codeblock of de AddRow()function.
A second problem is: when de line is repeated I need to reset de field values to default. Does anybody have the knowledge that I so obviously do not have?
======================================================================
<title>
function AddRow ()
{
var o_id = document.getElementById ("id").cloneNode(true);
var label_id = document.getElementById ("label_id").cloneNode(true);
var o_item = document.getElementById ("item").cloneNode(true);
var o_subitem = document.getElementById ("subitem").cloneNode(true);
var label_opm = document.getElementById ("label_opm").cloneNode(true);
var o_opm = document.getElementById ('opm').cloneNode(true);
// reset field opm
document.getElementById("opm").innerHTML="";
o_id.name='id[]';
o_item.name = 'item[]';
o_subitem.name = 'subitem[]';
o_opm.name = 'opm[]';
var o_button = document.createElement ("input");
o_button.type = "button";
o_button.value = "Remove";
o_button.onclick = RemoveRow;
var o_td_id = document.createElement ("td");
var o_td_item = document.createElement ("td");
var o_td_subitem = document.createElement ("td");
var o_td_opm = document.createElement ("td");
var o_td_button = document.createElement ("td");
var o_tr = document.createElement ("tr");
var o_body = document.getElementById ("dynamic_table_body");
o_td_id.appendChild (label_id);
o_td_id.appendChild (o_id);
o_td_item.appendChild (o_item);
o_td_subitem.appendChild (o_subitem);
o_td_opm.appendChild (label_opm);
o_td_opm.appendChild (o_opm);
o_td_button.appendChild (o_button);
o_tr.appendChild (o_td_id);
o_tr.appendChild (o_td_item);
o_tr.appendChild (o_td_subitem);
o_tr.appendChild (o_td_opm);
o_tr.appendChild (o_td_button);
//document.ovd.id.value++;
alert(o_item.value);
o_body.appendChild (o_tr);
}
function RemoveRow ()
{
var dinosaur = this.parentNode.parentNode;
dinosaur.parentNode.removeChild (dinosaur); //
}
OvD-Id
|
-- Choose Category --
Cat 1
Cat 2
Cat 3
|
-- Choose Sub Category --
Sub Cat 1
Sub Cat 2
Sub Cat 3
| Remarks
| Add OvD Item
|
|
|
|
|
|
I'd love to help, but I'm really not clear as to what you're asking here. Can you explain further?
Also, just a tip, put any code you must share inside of these tags: <pre></pre>
Do so by clicking the 'code' button above the message box. It makes your code a lot easier to read.
|
|
|
|
|
<title>
function AddRow ()
{
var o_id = document.getElementById ("id").cloneNode(true);
var label_id = document.getElementById ("label_id").cloneNode(true);
var o_item = document.getElementById ("item").cloneNode(true);
var o_subitem = document.getElementById ("subitem").cloneNode(true);
var label_opm = document.getElementById ("label_opm").cloneNode(true);
var o_opm = document.getElementById ('opm').cloneNode(true);
// reset field opm
document.getElementById("opm").innerHTML="";
o_id.name='id[]';
o_item.name = 'item[]';
o_subitem.name = 'subitem[]';
o_opm.name = 'opm[]';
var o_button = document.createElement ("input");
o_button.type = "button";
o_button.value = "Remove";
o_button.onclick = RemoveRow;
var o_td_id = document.createElement ("td");
var o_td_item = document.createElement ("td");
var o_td_subitem = document.createElement ("td");
var o_td_opm = document.createElement ("td");
var o_td_button = document.createElement ("td");
var o_tr = document.createElement ("tr");
var o_body = document.getElementById ("dynamic_table_body");
o_td_id.appendChild (label_id);
o_td_id.appendChild (o_id);
o_td_item.appendChild (o_item);
o_td_subitem.appendChild (o_subitem);
o_td_opm.appendChild (label_opm);
o_td_opm.appendChild (o_opm);
o_td_button.appendChild (o_button);
o_tr.appendChild (o_td_id);
o_tr.appendChild (o_td_item);
o_tr.appendChild (o_td_subitem);
o_tr.appendChild (o_td_opm);
o_tr.appendChild (o_td_button);
//document.ovd.id.value++;
alert(o_item.value);
o_body.appendChild (o_tr);
}
function RemoveRow ()
{
var dinosaur = this.parentNode.parentNode;
dinosaur.parentNode.removeChild (dinosaur); //
}
OvD-Id
|
-- Choose Category --
Cat 1
Cat 2
Cat 3
|
-- Choose Sub Category --
Sub Cat 1
Sub Cat 2
Sub Cat 3
| Remarks
| Add OvD Item
|
|
|
|
|
|
i want to create dynamic progress bar with respect to time. it means the progress bar increase with high value and decrease with low value automatically...
|
|
|
|
|
|
How can I emulate validation groups on jQuery UI Modal dialogs on asp.net webforms? I am using multiple modals on my webform but can't get this to work. 
|
|
|
|
|
Don't cross post. You have already asked this, and received responses, in the ASP.NET forum Read the forum guidelines please.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
I'm sorry I thought the fellows at javascript would answer better. 
|
|
|
|
|
Hi all
Iam New to javascript can you help me how to check the selected date is previous one?
eg:today is 14/8/2011 and i selected 12/8/2011 in a javascript calender i want to validate the selected date is previus one is it possible?
Please Help me
Arunkumar.T

|
|
|
|
|
|
function CompareDates(fromdate,todate) {
frmdt = new Date(fromdate.substring(6,10),fromdate.substring(3,5)-1,fromdate.substring(0,2));
todt = new Date(todate.substring(6,10),todate.substring(3,5)-1,todate.substring(0,2));
if ( todt.getTime() > frmdt.getTime() ) {
return 1;
}
else if( todt.getTime() == frmdt.getTime() ) {
return 0;
}
return -1;
}
Thanks & Regards,
Niral Soni
|
|
|
|
|
codeprojectforums.com Currently under Testing
-- Modified Thursday, August 11, 2011 7:37 AM
|
|
|
|
|
Hi,
I am looking for a solution, but not too sure what the problem is called?
For instance, if user is at one page for more than 30sec i want to have a like 3d pop up arrow showing the user where to go next? I am sure i have seen it in couple of sites but can't remember now. I think this can be achieved via jquery? Any examples or ideas how to get it sorted?
|
|
|
|
|
You are looking to implement an idle timeout, possibly like the one here[^].
|
|
|
|
|
As I mentioned in 'the other place', you don't need JQuery for this. Just set a timeout in body.onLoad which calls a function which puts a visible indicator (img or div) in the appropriate place. (Or starts an animation or whatever is appropriate.)
Do you want it for the user being on the page for 30s, or the user being inactive for 30s? If the latter, you need to hook keyboard and mouse click (probably not mouse move though) events on the document object and reset the timer.
|
|
|
|
|
ok to start with, just trying to load a simple image using javascript but it doesn't work.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
<script type="text/javascript">
function timeMsg()
{
var t=setTimeout('alertMsg()',3000);
}
function alertMsg()
{
var myImage;
myImage = new Image;
myImage.src = "images/test.png";
}
</script>
</head>
<body onload="timeMsg()">
</body>
</html>
Any idea,what am I doing wrong that it's not loading the image?
|
|
|
|