If buttonImage in .datePicker starts with a forward slash (/), Chrome does not find the image -


i have datepickers images being set in .js file jquery.

is ok remove leading / have done in buttonimage? jsfiddle below suggests chrome should able handle i'm wondering if i'm doing else wrong.

when setting buttonimage in .datepicker(), if location starts "/", chrome doesn't find image (404 behind scenes in chrome devtools). these lines .datepicker() below in question:

  • buttonimage: "content/images/cal.png", //working in browsers

  • buttonimage: "/content/images/cal_editor.jpg", //not working in
    chrome works in ie, firefox

however, when try replicate in simple jsfiddle, doesn't work in chrome without forward slash: http://jsfiddle.net/tonyleif/3z865d2r/2/.

from jsfiddle above:

  • buttonimage: "/img/initializing.png" //working in browsers

  • buttonimage: "img/initializing.png" //not working in browsers

here full .datepicker function being called in app:

var $calendarbutton = $(me).datepicker({     dateformat: "dd-m-yy",     showon: "button",     buttonimage: "content/images/cal.png", //working in browsers     //buttonimage: "/content/images/cal.png", //not working in chrome works in ie, firefox     buttonimageonly: true,     beforeshowday: onedayonlymethod,     altfield: alternatefield,     onselect: function() {         if ($(me).hasclass('searchitem')) {             app.searchtable.adddatefilter($(me));         }         var pairedname = $(me).attr('paired-date-picker');         if (pairedname !== undefined && pairedname.length > 0) {             var d = $(this).val();             if (isvaliddate(d.valueof())) {                 var pairedcontrol = $('#' + pairedname);                 if (pairedcontrol.val() == "" || pairedcontrol.val() == "dd-mmm-yy") {                     pairedcontrol.val(d);                 }             }         }         $(me).change();     } }).next(".ui-datepicker-trigger").addclass("calendar-button"); 

let me know if need more code this. i'm trying not include text initially.

one more thing should note when i'm running site locally visual studio 2013, don't have issue. happens when publish server.

the idea behind leading slash makes whole url relative root of site (http://sitename.blah/). without slash, relative path of lookup originated.

my guess you're attempting image directory other root, why works without slash on browsers.

comparing code jsfiddle fine, need compare file paths , relative site root. in jsfiddle, img folder @ root of site.

so answer question, no, it's not ok leave off slash unless mean file relative directory.


Comments

Popular posts from this blog

shopping cart - Page redirect not working PHP -

php - How to modify a menu to show sub-menus -

python - Installing PyDev in eclipse is failed -