def ko_bindings(model):
    """
    Given a model, returns the Knockout data bindings.
    """

    try:
        if isinstance(model, str):
            modelName = model
        else:
            modelName = model.__class__.__name__

        modelBindingsString = "ko.applyBindings(new " + modelName + "ViewModel(), $('#" + modelName.lower() + "s')[0]);"
        return modelBindingsString

    except Exception as e:
        logger.error(e)
        return ''