Well, I finally got everything working using your method, although i dumped
the use of $ since php wanted to consider them as variables even when in
quotes and when using xajax addscript returns. I am still puzzled why my
old method didn't work, but I am glad to have learned a new way of doing
things. Now I am getting more and more locked and hooked into jquery!!
Hope I never have to go back.
-jeremy
________________________________
From: Blair McKenzie [mailto:[EMAIL PROTECTED]
Sent: Friday, January 26, 2007 1:48 AM
To: [EMAIL PROTECTED]
Subject: Re: [jQuery] cant append() form objects
I use $ in the variable name to remind me that it is a jQuery object. Like
naming a variable aForms if it contains an array.
The problem with your id example is that because tst.$form is a jQuery
object and not the DOM element itself. DOM elements have id properties,
jQuery objects do not. Try:
alert(tst.$form[0].id);
Blair
On 1/26/07, Jeremy Dill <[EMAIL PROTECTED]> wrote:
Thanks. That does seem to work when it stands alone. I am having a hard
time making it work in my actual environment however. This test is overly
simplified to what I actually need. I tried using your method but I am
missing something. I am not sure I entirely understand the use of $ in
front of the ojbect name (like $layer). Is that just a preference or does
the $ do something in jquery that I should be aware of? Given your code
below, I should be able to reference the form object like this
tst=new appLayer('Test'); //create layer and layer objects.
tst.$form // this is the form object
alert(tst.$form.id) // this should alert the id of the form. right?
For some reason its not working that way.
Thanks again for your efforts.
Jeremy
________________________________
From: Blair McKenzie [mailto:[EMAIL PROTECTED]
Sent: Thursday, January 25, 2007 6:22 AM
To: [EMAIL PROTECTED]; jQuery Discussion.
Subject: Re: [jQuery] cant append() form objects
I refactored your function to use jQuery:
function appLayer(id){
//create layerbox
this.$layer = $("<div id='" + id + "_layer'
class='layerbox'></div>").appendTo("#content");
//create form
this.$layer.append(this.$form = $("<form id='" + id + "_form' name='" +
id + "_form' action='index.php' method='post'></form>"));
//create main div
this.$main = $("<div id='" + id + "_main'
class='morebox'></div>").html("This box should get created,
but it doesnt because form didnt get
created").prependTo(this.$form);
}
Interestingly, when I tryed to use
this.$form.appendTo(this.$layer) it didn't work. Is this a
bug? Not sure. But this function worked for me.
Blair
On 1/25/07, Jeremy Dill <[EMAIL PROTECTED]> wrote:
After upgrading from 1.0.4 to 1.1.1 the following code no longer works.
Please tell me if there is a solution to this issue.
-------------------------------WORKING HTML TEST
PAGE------------
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"
/>
<title>test</title>
<style>
.layerbox{font-size:8pt;text-align:left;padding:10px;margin:20px;border:1px
solid #B2C5EC; background-color:#FCFCFC;float:left;
clear:left;height:200px;width:200px}
</style>
<script type='text/javascript'
src='/js/jquery111.js'></script>
</head>
<body>
<div id='content'></div>
<script language="JavaScript">
function appLayer(id){
//create layerbox
var layerbox=document.createElement('div');
layerbox.id=id+"_layer";
layerbox.className="layerbox";
$("#content").prepend(layerbox);
this.divName=layerbox.id;
this.layerobj=layerbox;
//create form
var frm=document.createElement('form');
frm.id=id+"_form";
frm.name=id+"_form";
frm.action = "index.php";
frm.method = "post";
this.frm=frm.id;
//-------HERE IS THE PROBLEM-----///
$("#"+this.divName).append(frm);
//-------APPEND DOESNT WORK FOR FORM OBJECT------///
//create main div
var main=document.createElement('div');
main.id=id+"_main";
main.className="morebox";
main.innerHTML="This box should get created, but it doesnt because form
didnt get created";
$("#"+this.frm).prepend(main);
}
tst=new appLayer('Test');
</script>
</body>
</html>
----------------------------END PAGE-----------------
The form object does not get created. I don't have any problems
appending other objects such as divs, but the form object won't work
anymore.
It works fine in 1.0.4. Try it out.
Thanks in advance.
Jeremy
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/