1

I have a jquery datepicker which is already getting quite complicated but I want to add in another attribute to the td of certain dates

I already show certain dates as green based on a set of dates in an array (created based on options in a select menu), but I also want to add attributes with other info to these dates.

Here's the code I have so far (including the array for a price which I want to add):

$('.propertyAvailabilityCal').datepicker({
beforeShow: function(input, inst) {
    startDates = [];
    startPrice = [];
    selectdatesElem = $(input).siblings("select.startdates");
    $(input).siblings("select.startdates").find("option").each( function() {
          var startdateParts = $(this).val().split(', ');
              startDates.push(startdateParts[0] + ", " + (parseInt(startdateParts[1], 10)-1) + ", " + parseInt(startdateParts[2], 10));
    });
    $(input).siblings("select.startprice").find("option").each( function() {
          startPrice.push($(this).val());
    });


},
beforeShowDay: function(date) {

    for (i = 0; i < startDates.length; i++) {
          if (date.getFullYear()+", "+date.getMonth()+", "+date.getDate() == startDates[i]) {
                return [true, 'eventDay', date];
          }
    }

    return [false, ''];
}
});

And:

<select class="startPrice">
    <option value="274.95"></option>
    <option value="274.95"></option>
    <option value="274.95"></option>
    <option value="274.95"></option>
    <option value="274.95"></option>
</select>
<select class="startdates">
    <option value="2013, 06, 28"></option>
    <option value="2013, 07, 01"></option>
    <option value="2013, 07, 08"></option>
    <option value="2013, 07, 11"></option>
    <option value="2013, 07, 18"></option>
</select>

I want to be able to add the price as an attribute to that date. Is this even possible and if so does anyone know how?

Here's a jsfiddle to show what I want to achieve but with the price appearing rather than the date when you hover over a date...

http://jsfiddle.net/9tapA/

Thanks

1 Answer 1

2

try this

FIDDLE

btw, $(input).siblings("select.startPrice"). remember css selectors are case sensitive

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.