如何在图标上打开bootstrap-datepicker,而不仅仅是输入点击

时间:2016-01-22 12:03:22

标签: javascript jquery bootstrap-datepicker

是否可以在点击输入上打开日期选择器或使用日历图标打开跨度?

http://www.eyecon.ro/bootstrap-datepicker

我的代码

<div class="input-group datepicker">
<label>Date</label>
<input type="text" class="form-control" placeholder="YYYY-MM-DD" value="" name="date">
<span class="input-group-addon"><span class="glyphicon calendar"></span></span>
</div>


$(document).ready(function(){
    $('.datepicker').datepicker({'format': 'yyyy-mm-dd'});
});

Span保存日历图标,点击后我想显示日历。

这可能吗?怎么做?

1 个答案:

答案 0 :(得分:1)

您是否必须将该组件与日历图标一起使用?

您可以改为使用此处的第一个或第二个组件,并在输入中添加背景日历图像:

require 'json'
require 'yaml'

VAGRANTFILE_API_VERSION = "2"
confDir = $confDir ||= File.expand_path("~/.homestead")

homesteadYamlPath = confDir + "/Homestead.yaml"
homesteadJsonPath = confDir + "/Homestead.json"
afterScriptPath = confDir + "/after.sh"
aliasesPath = confDir + "/aliases"

require File.expand_path(File.dirname(__FILE__) + '/scripts/homestead.rb')

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
    if File.exists? aliasesPath then
        config.vm.provision "file", source: aliasesPath, destination: "~/.bash_aliases"
    end

    if File.exists? homesteadYamlPath then
        Homestead.configure(config, YAML::load(File.read(homesteadYamlPath)))
    elsif File.exists? homesteadJsonPath then
        Homestead.configure(config, JSON.parse(File.read(homesteadJsonPath)))
    end

    if File.exists? afterScriptPath then
        config.vm.provision "shell", path: afterScriptPath
    end

    ## HERE I added the setting ############################################
    config.vm.box = "laravel/homestead"
    ########################################################################
end