Search

DISCLAIMER: I'm still learning Javascript

I am having trouble understanding how to use symphonyPickable().

I only got as far as:

(function($) {
    $(document).ready(function() {
        $('#field-6').symphonyPickable();
        $('#field-3').symphonyPickable();
    });
})(jQuery.noConflict());

Then I'm stumped.

I am trying to use this to in a section entry page in the backend. I have one selectbox field and a few fields which I'd like to show/hide depending on the selection.
I would hugely appreciate a code sample of how to set up this function. Anyone?

Best, Tommaso

What are you trying to achieve? Please give us as much context as possible. Thanks!

Seems like I responded to fast and you adjusted your post in the meantime :)

You'll need some custom markup to get this working. This is how Pickable works:

  • .pickable() can be applied to a wrapper like a div or fieldset that contains a select box.
  • By default Pickable searches for the class .pickable to find elements that should be shown or hidden based on the select box setting.
  • In order to match the option values and the .pickable elements, each element needs to have an id of the option value it is connected to.

If you like to use another identifier for the pickable elements, you could pass an identifier with the call to Pickable:

$('#field-6').symphonyPickable({
    pickable: 'div.field-something'     
});

The most important part it to have the matching ids and values like so:

// Select
<select>
    <option value="this-is-a-test">This is a test</option>
    <option value="hello-world">Hello World!</option>
</select>

// Pickables
<div class="pickable" id="this-is-a-test">
    <p>I'm a Pickable element</p>
</div>
<div class="pickable" id="hello-world">
    <p>I'm another Pickable element</p>
</div>

Does this help a bit?

Big time yes! Thanks a lot for taking the time to explain it.

I guess I'll just add class names to some panels on the fly before calling the function. Btw, I'm loading this in via the HTMLPanel extension. Dirty hack?

Btw, I'm loading this in via the HTMLPanel extension. Dirty hack?

Your script file? It could be done via a small extension: have a look at Image Index Preview which does nothing but that: https://github.com/nilshoerrmann/image_index_preview

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details