[Project_owners] template confusion

Paul Tomlin paul at paultomlin.com
Tue Oct 11 18:50:13 EDT 2005


I have a bit of XUL, like the following, which generates a drop list of 
the available mail accounts within TB.

<menulist id="search.root.selected-account.uri"
   flex="1"
   sortResource="http://home.netscape.com/NC-rdf#Name"
   sortDirection="ascending"
   datasources="rdf:msgaccountmanager rdf:mailnewsfolders"
   containment="http://home.netscape.com/NC-rdf#child"
   ref="msgaccounts:/">

   <template xmlns:nc="http://home.netscape.com/NC-rdf#">
     <rule nc:ServerType="nntp" />
     <rule nc:IsServer="true">
       <menupopup>
         <menuitem uri="..."
                   value="..."
                   label="rdf:http://home.netscape.com/NC-rdf#Name" />
       </menupopup>
     </rule>
   </template>
</menulist>


I have registered an event listener via addEventListener

document.getElementById('my-dialog-id')
	.addEventListener('command', onCommand, true);

to handle all the command events. This is done tom simplfy the code and 
not have 15 million functions, 1 for each control. Not sure if this is 
ideal, but seems to make sense to me.

The above event listener works fine for most things, like radios and 
checkboxes. However, for the generated content in the menupopup I get 
the @uri value when inspecting event.target.id from within the event 
listener.

function onCommand(ev) { dump(ev.target.id); }

I'm not sure if it's possible but I think I'd like to be able to assign 
@id values to the menuitem such that I can be sure I know what they are 
when I see the event. At the moment I have to presume that if 
ev.target.id =~ |^mailbox://| then the event has come from the menupopup.

Neil, I've tried looking at your template tuts, but there's soooo many 
and I'm not too sure what I should be looking for in terms of language. 
If you have done an article about this then please nudge me in that 
direction :)

Otherwise, anyone got a clue how I should be doing this?



More information about the Project_owners mailing list