开发者

Update autoselect value option dynamically using Ajax.InPlaceCollectionEditor

开发者 https://www.devze.com 2022-12-17 21:44 出处:网络
I\'m using Scripaculous\' in place collection editor to present the user a with list of customers to assign to a contact dynamically.I am passing a value parameter as detailed in the documentation so

I'm using Scripaculous' in place collection editor to present the user a with list of customers to assign to a contact dynamically. I am passing a value parameter as detailed in the documentation so when the select is generated it will auto-select the current associated customer (if there is not one already the default is provided.)

This works well except when the user clicks on the 'edit me' field a second time the original value is selected, not the customer that was selected most r开发者_C百科ecently. This is because the original call to InPlaceCollectionEditor is unchanged. My question is whether there is any way to update the autoselect value without dynamically updating the entire scriptaculous call (this would mean selecting all the customers again via ajax, which is possible but not ideal.)

Here is the code:

<div id="editme">Test 1</div>
    <script type="text/javascript">

  new Ajax.InPlaceCollectionEditor(
    'editme', 
    '/usercustomer/editCustomer/id/811',
    { collection: [['192981', "Test 1"],['192893', "Test 2"],['192894', "Test 3"]  ... ],
      ajaxOptions: {method: 'get'}
      , value: 192893 } // specifying the value parameter auto selects object id 192893
   );
</script>

Is this a limitation of InPlaceCollectionEditor or is there some other way around this?


Pass a variable instead of the hardcoded number as 'value'. Set that variable to the initial or selected value right before making the call.

0

精彩评论

暂无评论...
验证码 换一张
取 消