I'm having trouble displaying two Playa single select fields in a SafeCracker form that is dynamically loaded via Ajax with jQuery. I have tried everything suggested in P&T's Get Satisfaction support area, but nothing's working.
Here is my case:
I have a channel named Orders and a channel named Traders. When I make a new order, I want to assign a Buying trader and Selling trader via a Playa field.
I have a site/index template that is loading orders/_orders template via ajax.
In the order/_orders template is a exp:channel:entries loop wit all my Orders. There is also a SafeCracker form around 3 checkboxes in each order.
Every order has an Edit button, that, when clicked, loads a SafeCracker form for that particular Order via Ajax. The template is: orders/_order-editForm/{entry_id}
The edit Order form containing the SafeCracker form holds two Playa single select fields which are embedded like this (one for Buyers and one for Sellers):
<select class="chzn-select" name="buyer_trader[selections][]" style="width:200px;">
{embed='orders/_order-buyer-dropdown' entry_id="{buyer_trader}{entry_id}{/buyer_trader}"}
</select>
and
<select class="chzn-select" name="seller_trader[selections][]" style="width:200px;">
{embed='orders/_order-seller-dropdown' entry_id="{seller_trader}{entry_id}{/seller_trader}"}
</select>
As you can see I'm embedding the entry_id of the selected buyer and seller to set the corresponding buyer and seller as 'selected' in the select field inside the embedded template.
Inside the orders/_order-buyer-dropdown and orders/_order-seller-dropdown templates, I have the exp:channel:entries loop like this:
{exp:channel:entries channel="traders" dynamic="no" disable="categories|member_data|pagination"}
<option value="{entry_id}" {if "{entry_id}" == "{embed:entry_id}"}selected{/if}>
{trader-name}
</option>
{/exp:channel:entries}
The issue is dat the selected Traders are not showing the right trader. The orders Are showing the correct trader. On submitting the forms everything IS working. And the correct Traders Are being submitted. The only issue (that I have been tackling for the past 3 days) is that when I want to edit an order, the select boxes are not showing the correct traders as 'selected'.
The only way I do get it to work is when I use {field:buyer_trader} / {field:seller_trader}, except I shows me the Playa styled version of the select box, and I don't want that.
What am I doing wrong?