How to load pre selected items of a jquery selectable

How to load pre selected items of a jquery selectable

I am currently using a jquery selectable which stores values to a database i would like to create a view page where the users can view which elements were selected.

I was given the following code 
  1. $(function() {
  2.     $("#selectable").selectable({
  3.         create: function( event, ui ) {
  4.             var list=JSON.parse(localStorage.selectableList)
  5.             $(this).children().filter(function(){
  6.                 return $.inArray($(this).text(),list) !== -1
  7.             }).addClass("ui-selected")
  8.         },
  9.         stop: function(event, ui) {
  10.             var list = $(".ui-selected", this).map(function() {
  11.                 return $(this).text()
  12.             }).get()
  13.             localStorage.selectableList = JSON.stringify(list)
  14.         }
  15.     })
  16. });  
Problem is i am unable to get the values of that i am passing to from the database to load so for e.g. if i have the values 1,2,3,4,5 saved in the database i have the values passed to an array or a string value seperated by , how can i get these values to be pre-selected?