Quantcast
Channel: jQuery Library for SharePoint Web Services
Viewing all articles
Browse latest Browse all 6517

New Post: SPComplexToSimpleDropdown - Default value not taken into account

$
0
0
Hello,

I have implemented (what I thought was) a fantastic tweak on SP 2010 using SPServices, but it seems there is a bug.

Context:
I have 2 Lists:
  • Trainings
  • Enrollments (which contains a lookup field: Training, from the list above)
I am calling the Enrollments NewItem form, with a parameter in the URL (the ID of the training), and I use the parameter to pre-select the corresponding value in the dropdown list. In order to achieve this, I have found no other way than to overwrite the default dropdown by using SPComplexToSimpleDropdown.

The code is integrated in a separate html file, and included in the form via a Content Editor.

It is working fine. Or so I thought.
<script type="text/javascript">
    $(document).ready(function (){
        var selects = $('.ms-lookuptypeintextbox');
        if (selects.length > 0) {
            $(selects).each(function(index, value) {
                $().SPServices.SPComplexToSimpleDropdown({
                    columnName: $(this).attr('title') 
                }); 
            });
        }

    document.getElementById("SPComplexToSimpleDropdown_Training").value = GetURLParameter('Training');

    function GetURLParameter(sParam)
    {
        // this function works and is out of context
    }
    
    });
</script>
Here's the catch:
  • if I change the value of the dropdown, the value is saved OK;
  • if I leave the default value, however, the item is saved with a wrong value, as if it was taking into account the value of the "actual" (hidden) SP Dropdown instead of the visible one.
Do I need to trigger an additional event for this to work?
any info welcome. I hope my request is clear and hasn't already been answered elsewhere.

FYI I am running jQuery 1.7.2 and SPServices 0.7.1a

Have a nice day,
Hubert.

Viewing all articles
Browse latest Browse all 6517

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>