On Thursday, April 7, 2016 at 8:18:59 AM UTC-7, Hegart Dmishiv wrote:
>
> I'm making a start on that idea of cascading the selection from one 
> *<<combobox>>* into the filter for the options of another. However, in 
> the second example on this experiment tiddler 
> <https://tiddlytest.github.io/#Playing%20with%20Eric%27s%20combobox%20and%20the%20%22okaction%22%20param>,
>  
> I'm stuck with a bit of a problem. Despite having specified field:"city" 
> as the field from which the *option value* should be stored, it still 
> seems to be storing the *title* of the selected option, rather than the 
> *city*. The *option labels* are being populated properly, using your 
> example above of template:"{{!!city}}", but the *option values* aren't 
> respecting the field: parameter.
>

The built-in (hardcoded) combobox list "click" handler performs this action:
<$action-setfield $tiddler="""$tiddler$""" $field="""$field$""" 
$index="""$index$""" $value=<<currentTiddler>>/>
i.e., when you click a list item, it sets the target field (or index) to 
the <<currentTiddler>> value (which is the title of the selected tiddler).

To set a different value when an item is clicked, you can specify a custom 
"clickaction" param in the macro call so that after the current title value 
is set, you can overwrite it with the value from the desired field instead.

First, to avoid nested use of """, define the click action as a separate 
macro:

\define myaction() 
<$action-setfield $tiddler="""$tiddler$""" $field="""$field$""" 
$index="""$index$""" $value={{!!fieldname}}/>
\end

Note that this macro is performing the same handling as the built-in click 
handler, but sets the value from a specified field, rather than using 
<<currentTiddler>>.

Then, to use this "action macro", add this param to your combobox macro 
call:
clickaction:"""<<myaction>>"""

Note the use of the tripled-quotes so that the call to <<myaction>> is NOT 
parsed, but is simply passed as literal text that is inserted into the 
combobox code and only invoked when an item is actually clicked upon.

let me know how is goes...

enjoy,
-e

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/02f3cb5b-9b6a-4cf2-a59d-42c62101d10d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to