[mochikit] Node attributes show up in IE but not in Firefox
Using MochiKit.DOM I'm creating a MAP node which contains a list of AREA nodes. While it works for IE it seems that when the MAP is created in Firefox not all of my attributes make it into the DOM. Is there something extra I need to do for this to work in Firefox? Here is my code in which I am generating the MAP and AREA nodes from a file containing JSON formatted area IDs and coords: var AREA = createDOMFunc('area'); var MAP = createDOMFunc('map'); function foo(a) { sa = new Array(); sa = a[0].split(','); var str = sa[1]+','+sa[2]+','+sa[3]+','+sa[4]; var mofooStr = 'mofoo(\''+sa[0]+'\')'; var mobarStr = 'mobar(\''+sa[0]+'\')'; return AREA({'id':sa[0],'shape':'rect','coords':str,'onmouseover':mofooStr,'onclick':mobarStr}); } function loadImageMapCallback(result) { a = new Array(); var newImageMap = MAP({'id':'tmMap'},map(foo,result.areas)); swapDOM('tmMap',newImageMap); } function loadImageMapErrback(err) { alert('Problem loading image map'); } function loadImageMap() { var d = loadJSONDoc("map.json"); d.addCallback(loadImageMapCallback); d.addErrback(loadImageMapErrback); } ** The map.json file looks something like: { "areas": [ ["1,2,18,21,39"], ["2,2,40,21,60"], ["3,2,61,21,81"], ["4,2,82,21,102"], ["5,2,103,21,122"], ... ] } * After the loadImageMap method is called in IE I'm assuming the AREA nodes look something like: because I can mouseover and click on my image and I see the expected calls to mofoo and mobar. In Firefox I can examine the HTML (using firebug...way cool! Is there something like firebug for IE?) and my AREA nodes sadly look like this: My onmouseover and onclick attributes are missing. Is this a known problem or a side effect? Is there a better approach? Thanks in advance! Evan --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "MochiKit" group. To post to this group, send email to mochikit@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/mochikit?hl=en -~--~~~~--~~--~--~---
[mochikit] Re: create form in document
Thanks bob/kieran, - I used INPUT() and it works ok. - I'm still sorting out the DOM structures in my head... but it'll make sense soon. now I'm sure I already know the answer to this... but I guess I'll ask the experts: Is there anyway to side-step the browser security to enter a form field value in a foreign window/page. ie, copy the DOM or something? Cheers :) On Jul 16, 4:33 pm, "Bob Ippolito" <[EMAIL PROTECTED]> wrote: > On 7/16/07, Kieran O'Neill <[EMAIL PROTECTED]> wrote: > > > > > > > On 7/16/07, Bob Ippolito <[EMAIL PROTECTED]> wrote: > > > > On 7/16/07, MerlinTheCat <[EMAIL PROTECTED]> wrote: > > > > > Hi, I'm well versed in JS - but I've been struggling to understand > > > > MochiKit for a couple of days... help from anyone who can clear my > > > > brainblock would be appreciated. Thanks. > > > > > I'm trying to add a form on the page dynamically. The H1 and [object > > > > Object] form? gets displayed on the page... but I can't see the form > > > > or access any of it's fields or submit it??? > > > > > Here's my code: > > > > > MochiKit.DOM.withWindow(self.window, MochiKit.Base.bind( function() { > > > > > var doc = MochiKit.DOM.currentDocument(); > > > > MochiKit.DOM.appendChildNodes(doc.body, H1(null,"This gets added > > > > OK")); > > > > > var formObj = MochiKit.DOM.FORM({"id":"myForm", > > > > "action":"test01.asp", "method":"post"}, {"inputs": [{"type":"text", > > > > "id":"field1", "name":"field1", "value":"newval"}, {"type":"submit", > > > > "name":"mySubmit", "value":"mySubmit"}]}); > > > > > MochiKit.DOM.appendChildNodes(doc.body, formObj); > > > > > alert(doc.body.formObj.field1); // this indicates undefined? > > > > alert(doc.formObj.field1); // this indicates undefined? > > > > > }, this)); > > > > That's because the code you wrote doesn't make any sense. {"inputs": [ > > > ... ]} isn't going to do anything. You need to do the same thing > > > you're doing with FORM, except with INPUT. > > > > FORM(attrs, INPUT(attrs), INPUT(attrs), ...) > > > > -bob > > > You should try getting a DOM inspector. It's extremely useful for > > working out what is and isn't being produced in complex DOM creation > > code. Firebug has a good one. > > > Also, as Bob said, the functions FORM, INPUT, etc work on a > > per-element basis, since they are just partially executed calls to > > createDOM. (eg: FORM == partial(createDOM, "FORM") ) > > > createDOM, and hence all these functions, takes two arguments after > > the DOM element type is specified: the attributes of the element (as a > > dictionary), and the elements to nest within it (as an Array). The > > nested elements need to either be constructed DOM objects, or objects > > that can be coerced into DOM objects, such as strings. > > createDOM takes one attribute argument and every other argument is > coerced into a child node. You don't need to use an Array, but if you > do use an one somewhere in the tree it'll get flattened. > > -bob- Hide quoted text - > > - Show quoted text - --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "MochiKit" group. To post to this group, send email to mochikit@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/mochikit?hl=en -~--~~~~--~~--~--~---
[mochikit] Re: create form in document
On 7/16/07, Kieran O'Neill <[EMAIL PROTECTED]> wrote: > On 7/16/07, Bob Ippolito <[EMAIL PROTECTED]> wrote: > > > > On 7/16/07, MerlinTheCat <[EMAIL PROTECTED]> wrote: > > > > > > Hi, I'm well versed in JS - but I've been struggling to understand > > > MochiKit for a couple of days... help from anyone who can clear my > > > brainblock would be appreciated. Thanks. > > > > > > I'm trying to add a form on the page dynamically. The H1 and [object > > > Object] form? gets displayed on the page... but I can't see the form > > > or access any of it's fields or submit it??? > > > > > > Here's my code: > > > > > > > > > MochiKit.DOM.withWindow(self.window, MochiKit.Base.bind( function() { > > > > > > var doc = MochiKit.DOM.currentDocument(); > > > MochiKit.DOM.appendChildNodes(doc.body, H1(null,"This gets added > > > OK")); > > > > > > var formObj = MochiKit.DOM.FORM({"id":"myForm", > > > "action":"test01.asp", "method":"post"}, {"inputs": [{"type":"text", > > > "id":"field1", "name":"field1", "value":"newval"}, {"type":"submit", > > > "name":"mySubmit", "value":"mySubmit"}]}); > > > > > > MochiKit.DOM.appendChildNodes(doc.body, formObj); > > > > > > alert(doc.body.formObj.field1); // this indicates undefined? > > > alert(doc.formObj.field1); // this indicates undefined? > > > > > > }, this)); > > > > That's because the code you wrote doesn't make any sense. {"inputs": [ > > ... ]} isn't going to do anything. You need to do the same thing > > you're doing with FORM, except with INPUT. > > > > FORM(attrs, INPUT(attrs), INPUT(attrs), ...) > > > > -bob > > > You should try getting a DOM inspector. It's extremely useful for > working out what is and isn't being produced in complex DOM creation > code. Firebug has a good one. > > Also, as Bob said, the functions FORM, INPUT, etc work on a > per-element basis, since they are just partially executed calls to > createDOM. (eg: FORM == partial(createDOM, "FORM") ) > > createDOM, and hence all these functions, takes two arguments after > the DOM element type is specified: the attributes of the element (as a > dictionary), and the elements to nest within it (as an Array). The > nested elements need to either be constructed DOM objects, or objects > that can be coerced into DOM objects, such as strings. createDOM takes one attribute argument and every other argument is coerced into a child node. You don't need to use an Array, but if you do use an one somewhere in the tree it'll get flattened. -bob --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "MochiKit" group. To post to this group, send email to mochikit@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/mochikit?hl=en -~--~~~~--~~--~--~---
[mochikit] Re: create form in document
On 7/16/07, Bob Ippolito <[EMAIL PROTECTED]> wrote: > > On 7/16/07, MerlinTheCat <[EMAIL PROTECTED]> wrote: > > > > Hi, I'm well versed in JS - but I've been struggling to understand > > MochiKit for a couple of days... help from anyone who can clear my > > brainblock would be appreciated. Thanks. > > > > I'm trying to add a form on the page dynamically. The H1 and [object > > Object] form? gets displayed on the page... but I can't see the form > > or access any of it's fields or submit it??? > > > > Here's my code: > > > > > > MochiKit.DOM.withWindow(self.window, MochiKit.Base.bind( function() { > > > > var doc = MochiKit.DOM.currentDocument(); > > MochiKit.DOM.appendChildNodes(doc.body, H1(null,"This gets added > > OK")); > > > > var formObj = MochiKit.DOM.FORM({"id":"myForm", > > "action":"test01.asp", "method":"post"}, {"inputs": [{"type":"text", > > "id":"field1", "name":"field1", "value":"newval"}, {"type":"submit", > > "name":"mySubmit", "value":"mySubmit"}]}); > > > > MochiKit.DOM.appendChildNodes(doc.body, formObj); > > > > alert(doc.body.formObj.field1); // this indicates undefined? > > alert(doc.formObj.field1); // this indicates undefined? > > > > }, this)); > > That's because the code you wrote doesn't make any sense. {"inputs": [ > ... ]} isn't going to do anything. You need to do the same thing > you're doing with FORM, except with INPUT. > > FORM(attrs, INPUT(attrs), INPUT(attrs), ...) > > -bob > You should try getting a DOM inspector. It's extremely useful for working out what is and isn't being produced in complex DOM creation code. Firebug has a good one. Also, as Bob said, the functions FORM, INPUT, etc work on a per-element basis, since they are just partially executed calls to createDOM. (eg: FORM == partial(createDOM, "FORM") ) createDOM, and hence all these functions, takes two arguments after the DOM element type is specified: the attributes of the element (as a dictionary), and the elements to nest within it (as an Array). The nested elements need to either be constructed DOM objects, or objects that can be coerced into DOM objects, such as strings. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "MochiKit" group. To post to this group, send email to mochikit@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/mochikit?hl=en -~--~~~~--~~--~--~---
[mochikit] Re: create form in document
On 7/16/07, MerlinTheCat <[EMAIL PROTECTED]> wrote: > > Hi, I'm well versed in JS - but I've been struggling to understand > MochiKit for a couple of days... help from anyone who can clear my > brainblock would be appreciated. Thanks. > > I'm trying to add a form on the page dynamically. The H1 and [object > Object] form? gets displayed on the page... but I can't see the form > or access any of it's fields or submit it??? > > Here's my code: > > > MochiKit.DOM.withWindow(self.window, MochiKit.Base.bind( function() { > > var doc = MochiKit.DOM.currentDocument(); > MochiKit.DOM.appendChildNodes(doc.body, H1(null,"This gets added > OK")); > > var formObj = MochiKit.DOM.FORM({"id":"myForm", > "action":"test01.asp", "method":"post"}, {"inputs": [{"type":"text", > "id":"field1", "name":"field1", "value":"newval"}, {"type":"submit", > "name":"mySubmit", "value":"mySubmit"}]}); > > MochiKit.DOM.appendChildNodes(doc.body, formObj); > > alert(doc.body.formObj.field1); // this indicates undefined? > alert(doc.formObj.field1); // this indicates undefined? > > }, this)); That's because the code you wrote doesn't make any sense. {"inputs": [ ... ]} isn't going to do anything. You need to do the same thing you're doing with FORM, except with INPUT. FORM(attrs, INPUT(attrs), INPUT(attrs), ...) -bob --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "MochiKit" group. To post to this group, send email to mochikit@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/mochikit?hl=en -~--~~~~--~~--~--~---
[mochikit] create form in document
Hi, I'm well versed in JS - but I've been struggling to understand MochiKit for a couple of days... help from anyone who can clear my brainblock would be appreciated. Thanks. I'm trying to add a form on the page dynamically. The H1 and [object Object] form? gets displayed on the page... but I can't see the form or access any of it's fields or submit it??? Here's my code: MochiKit.DOM.withWindow(self.window, MochiKit.Base.bind( function() { var doc = MochiKit.DOM.currentDocument(); MochiKit.DOM.appendChildNodes(doc.body, H1(null,"This gets added OK")); var formObj = MochiKit.DOM.FORM({"id":"myForm", "action":"test01.asp", "method":"post"}, {"inputs": [{"type":"text", "id":"field1", "name":"field1", "value":"newval"}, {"type":"submit", "name":"mySubmit", "value":"mySubmit"}]}); MochiKit.DOM.appendChildNodes(doc.body, formObj); alert(doc.body.formObj.field1); // this indicates undefined? alert(doc.formObj.field1); // this indicates undefined? }, this)); --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "MochiKit" group. To post to this group, send email to mochikit@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/mochikit?hl=en -~--~~~~--~~--~--~---
[mochikit] Re: Internet Explorer compatibility problem
i declared the variable and it works, thanks ;) On 14 Lug, 10:29, SanderElias <[EMAIL PROTECTED]> wrote: > Hi, > > I did not test this, but I suspect you are using a 'reserved word' as > an variable name. > This is not an good idea, and IE is much more vulnerable to this kind > off stuff. > try renaming your parent variable to something like myParent or so! > > I hope this helps > with kind regards > Sander Elias --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "MochiKit" group. To post to this group, send email to mochikit@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/mochikit?hl=en -~--~~~~--~~--~--~---