0

I try to use a Bootstrap timepicker.

My VF page :

<apex:page controller="MyController">
    <script type="text/javascript" src="{!URLFOR($Resource.Bootstrap, '/js/bootstrap-timepicker.min.js')}"></script>
    <apex:stylesheet value="{!URLFOR($Resource.Bootstrap, '/css/bootstrap-timepicker.min.css')}"/>
    <apex:includeScript value="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"/>
    <apex:includeScript value="https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.1/jquery-ui.min.js"/>
    <script>jQuery.noConflict();</script> 

    <apex:form>
       <div class="input-append bootstrap-timepicker">
            <input id="timepicker1" type="text" class="input-small"/>
            <span class="add-on"><i class="icon-time"></i></span>
       </div>
    </apex:form>

    <script type="text/javascript">
        $('#timepicker1').timepicker();
    </script>
</apex:page>

But I have this error :

TypeError: $(...) is null

I use this link to do it : http://jdewit.github.io/bootstrap-timepicker/

1
  • In the past I have had to assign the result of noConflict to a local variable and use that to perform jQuery work. Nov 12, 2014 at 13:41

1 Answer 1

2

The problem is the <script>jQuery.noConflict();</script> line. This tells jQuery to release control of the $ variable back to whatever was using it before jQuery loaded.

You would either need to remove that line, or change the later script to reference the jQuery variable rather than the $ variable

i.e. jQuery('#timepicker1').timepicker();

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .