[webkit-help] valueForKeyPath

Eric Lease Morgan eric_morgan at infomotions.com
Sun Mar 28 15:24:18 PDT 2010

Is this a place where I can ask for some help on the valueForKeyPath method as implemented in Javascript in a WebKit browser such as Mobile Safari? If not, then where is a better venue for my question?

In Dashcode I have defined a data source from an remote XML file, and the XML looks like this:

        <name water_id='79'>Agean Sea at Kos, Greece</name>
          <collector collector_id='20'>
        <description>Pascal collected...</description>
        <name water_id='37'>Amazon River, Peru</name>
          <collector collector_id='8'>
        <description>Mom collected...</description>

I have then bound elements like name, last_name, and description to various interface elements. Through Javascript I have been able to manipulate these elements as well the collector_id attribute. All this works as expected.

Unfortunately, I am unable to access the water_id attribute. While the water_id attribute displays as a part of my data source and list views, whenever I try to actually access the water_id attribute my application crashes as illustrated by the linked screen shot. [1]

To debug the situation I created a button with the following code using the valueForKeyPath, and as you can see I can access other elements and attributes but not the water_id attribute:

  function getID(event)
    // get my data
    var d = dashcode.getDataSource( 'list' );
    // the following code works
    //var r = d.valueForKeyPath( 'selection.collectors.collector.$collector_id' );
    // this code works too
    //var r = d.valueForKeyPath( 'selection.collectors.collector.last_name' );
    // so does this code
    //var r = d.valueForKeyPath( 'selection.name' );
    // why doesn't this code work! water_id is an attribute of the name element
    var r = d.valueForKeyPath( 'selection.name.$water_id' );
    // echo
    alert( r );

What am I doing wrong? Any assistance or pointers would be greatly appreciated.

[1] screen shot - http://infomotions.com/tmp/screen-dump.png

Eric Lease Morgan

More information about the webkit-help mailing list