Setting handle values

manuman94 edited this page May 7, 2014 · 7 revisions

Setting handle values

ytCropper library has methods to set the handle values.

  • ytCropper::setInitialValue(value)
    Function that changes the initial value of the interval.

value -> Value in seconds

Returns true if the value is valid and false if not.

  • ytCropper::setFinalValue(value)
    Función que cambia el valor final del intervalo.

value -> Value in seconds

Returns true if the value is valid and false if not.

Example:

$("#generateButton").on("click",function(e)
{
    errores = "";

        // Prevent the default behaviour of <a> tag
    e.preventDefault();
        // Obtain the first value and put it into #firstInput
    if($("#firstInput").val() != '') // If the #firstInput is set
    {
        if(!cropper.setInitialValue($("#firstInput").val()))
        {
            errores += "The first value is not valid. ";
        }
    }
        // Obtain the second value and put it into #secondInput
    if($("#secondInput").val() != '') // If the #secondInput is set
    {
        if(!cropper.setFinalValue($("#secondInput").val()))
        {
            errores += "The second value is not valid ";
        }
    }

    $("#generatedCode").val(errores);

});

This piece of code take the #firstInput and #secondInput values and set them to the handles. If values are not valid the #generatedCode textfield will show the error.

You can test it here: http://jsfiddle.net/BxQhy/13/

More information about this library in this wiki.