       if item.docid?
         add_model_static(elem, item.modelid, docs[item.docid])
       else if item.sessionid?
-        promise = add_model_from_session(elem, item.modelid, item.sessionid)
+        promise = add_model_from_session(elem, websocket_url, item.modelid, item.sessionid)
       else
         throw new Error("Error rendering Bokeh model #{item['modelid']} to element #{element_id}: no document ID or session ID specified")
     else
       if item.docid?
          add_document_static(elem, docs[item.docid], use_for_title)
       else if item.sessionid?
-         promise = add_document_from_session(elem, item.sessionid, use_for_title)
+         promise = add_document_from_session(elem, websocket_url, item.sessionid, use_for_title)
       else
         throw new Error("Error rendering Bokeh document to element #{element_id}: no document ID or session ID specified")
 

  )

# Replace element with a view of model_id from the given session
add_model_from_session = (element, model_id, session_id) ->
  promise = _get_session(session_id)
  promise.then(
    (session) ->
      model = session.document.get_model_by_id(model_id)

  logger.info("Will inject Bokeh script tag with params #{JSON.stringify(item)}")

embed_items = (docs_json, render_items, websocket_url) ->
  docs = {}
  for docid of docs_json
    docs[docid] = Document.from_json(docs_json[docid])
