Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>herby</strong>'s excellent answer points out the <strong>recommended</strong> way to do it. Appearently, there is now Dictionary-literal support (see his comment below). Didn't know that :-)</p> <h2>Old / Alternate way of doing it</h2> <p>For historical reasons, or for users not using the latest master version, this is an alternative way to do it:</p> <pre><code>options := &lt;{}&gt;. options at: #axis put: 'y'. '#draggable' asJQuery draggable: options. </code></pre> <p>The first line constructs an empty JavaScript object (it's really an <code>JSObjectProxy</code>).</p> <p>The second line puts the string "y" in the slot "axis". It has the same effect as:</p> <pre><code>options.axis = "y"; // JavaScript </code></pre> <p>Lastly, it is invoked, and passed as a parameter.</p> <h2>Array-literals vs Dictionaries</h2> <p>What you were doing didn't work because in modern Smalltalk (Pharo/Squeak/Amber) the curly-brackets are used for array-literals, not as an object-literal as they are used in JavaScript.</p> <p>If you evaluate (print-it) this in a Workspace:</p> <pre><code>{ #elelemt1. #element2. #element3 }. </code></pre> <p>You get:</p> <pre><code>a Array (#elelemt1 #element2 #element3) </code></pre> <p>As a result, if you have something that <em>looks</em> like a JavaScript object-literal in reality it is an Array of Association(s). To illustrate I give you this snippet, with the results of print-it on the right:</p> <pre><code>arrayLookingLikeObject := { #key1 -&gt; #value1. #key2 -&gt; #value2. #key3 -&gt; #value3}. arrayLookingLikeObject class. "==&gt; Array" arrayLookingLikeObject first class. "==&gt; Association" arrayLookingLikeObject "==&gt; a Array (a Association a Association a Association)" </code></pre> <p>I wrote about it here:</p> <p><a href="http://smalltalkreloaded.blogspot.co.at/2012/04/javascript-objects-back-and-forth.html" rel="nofollow">http://smalltalkreloaded.blogspot.co.at/2012/04/javascript-objects-back-and-forth.html</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload