|
|||
Warum willst du keine Infos hergeben, was genau nicht funktioniert?
geh auf jsfiddle.net und füge folgendes in den html-teil ein: <span data-time="1428051728" class="countdown-1">TEST</span> (Dein code, mit einem test-wert drinnen damit man das div auch sieht. Das hat keine Auswirkungen auf irgendwas Stell links ein, dass jquery verwendet wird und füge folgende Zeile bei javascript ein: $(".countdown-1").attr("data-time","500"); (Dein unveränderter Code) führe das ganze dann aus und untersuche im rechten unteren Fenster dann das div mit dem Wert TEST... Das hat einen data-time von 500. Es funktioniert also. |
Sponsored Links |
|
|||
ja komisch, da funktionierts.
bei mir nicht :/ welche Infos brauchst du denn? Firebug gibt keine Fehler ich nutze diesen countdown: http://krzysztof-furtak.pl/kk-countdown-jquery-plugin/ Geändert von SpecialFighter (03.04.2015 um 12:35 Uhr) |
|
|||
das ist die js. datei vom countdown:
Code:
// Generated by CoffeeScript 1.8.0 (function() { var KKCountdown; KKCountdown = (function() { KKCountdown.prototype.version = '1.4.2'; KKCountdown.prototype.defaults = { dayText: '', days2Text: '', daysText: '', hourText: '', hours2Text: '', hoursText: '', minutesText: ':', secondsText: '', textAfterCount: '', oneDayClass: false, displayDays: false, displayZeroDays: false, addClass: false, callback: false, warnSeconds: 60, warnClass: false, rusNumbers: false, boxContenerClass: 'kkcountdown-box', boxDaysClass: 'kkc-days', boxHoursClass: 'kkc-hours', boxMinClass: 'kkc-min', boxSecClass: 'kkc-sec', boxDaysTextClass: 'kkc-days-text', boxHoursTextClass: 'kkc-hours-text', boxMinTextClass: 'kkc-min-text', boxSecTextClass: 'kkc-sec-text' }; function KKCountdown(el, options) { var _this; _this = this; this.opts = $.extend({}, this.defaults, options); this.$el = $(el); this.countdowns = []; this.prepareHTML(); this.countdownInit(this.$el); this.$el.on('countdown:reset', function() { return _this.reset(_this.$el); }); } KKCountdown.prototype.prepareHTML = function() { var box, boxDays, boxDaysText, boxHours, boxHoursText, boxMin, boxMinText, boxSec, boxSecText, _this; _this = this; box = $(document.createElement('span')).addClass(_this.opts.boxContenerClass); boxDays = $(document.createElement('span')).addClass(_this.opts.boxDaysClass); boxHours = $(document.createElement('span')).addClass(_this.opts.boxHoursClass); boxMin = $(document.createElement('span')).addClass(_this.opts.boxMinClass); boxSec = $(document.createElement('span')).addClass(_this.opts.boxSecClass); boxDaysText = $(document.createElement('span')).addClass(_this.opts.boxDaysTextClass); boxHoursText = $(document.createElement('span')).addClass(_this.opts.boxHoursTextClass); boxMinText = $(document.createElement('span')).addClass(_this.opts.boxMinTextClass); boxSecText = $(document.createElement('span')).addClass(_this.opts.boxSecTextClass); if (_this.opts.addClass) { box.addClass(_this.opts.addClass); } boxHoursText.html(_this.opts.hoursText); boxMinText.html(_this.opts.minutesText); boxSecText.html(_this.opts.secondsText); box.append(boxDays).append(boxDaysText).append(boxHours).append(boxHoursText).append(boxMin).append(boxMinText).append(boxSec).append(boxSecText); return this.$el.append(box); }; KKCountdown.prototype.reset = function(obj) { if (obj.id !== void 0) { return obj.id = null; } }; KKCountdown.prototype.countdownInit = function(obj) { var count, event, now, _this; count = 0; _this = this; if (obj.id === void 0 || obj.id === null) { obj.id = 'kk_' + Math.random(new Date().getTime()); } if (_this.countdowns[obj.id] || _this.countdowns[obj.id] === 0) { count = _this.countdowns[obj.id]; } else { count = obj.data('seconds'); } if (count === void 0) { now = new Date(); now = Math.floor(now.getTime() / 1000); event = obj.data('time'); if (event === void 0) { event = obj.attr('time'); } count = event - now; } _this.countdowns[obj.id] = count - 1; if (_this.opts.warnClass && count < _this.opts.warnSeconds) { obj.addClass(_this.opts.warnClass); } if (count <= 0) { obj.html(_this.opts.textAfterCount); if (_this.opts.callback) { return _this.opts.callback.call(obj); } } else if (count <= 24 * 60 * 60) { this.countdown(true, obj, count); return setTimeout(function() { return _this.countdownInit(obj); }, 1000); } else { this.countdown(false, obj, count); return setTimeout(function() { return _this.countdownInit(obj); }, 1000); } }; KKCountdown.prototype.countdown = function(warning, obj, count) { var days, hours, minutes, seconds, _this; _this = this; seconds = this.fixTime(count % 60); count = Math.floor(count / 60); minutes = this.fixTime(count % 60); count = Math.floor(count / 60); hours = this.fixTime(count % 24); count = Math.floor(count / 24); days = count; if (_this.opts.oneDayClass && warning) { obj.addClass(_this.opts.oneDayClass); } if (_this.opts.displayDays) { if (days === 0 && _this.opts.displayZeroDays) { obj.find('.' + _this.opts.boxDaysClass).html(days); obj.find('.' + _this.opts.boxDaysTextClass).html(this.formatText(days, 'day')); } else if (days > 0) { obj.find('.' + _this.opts.boxDaysClass).html(days); obj.find('.' + _this.opts.boxDaysTextClass).html(this.formatText(days, 'day')); } } obj.find('.' + _this.opts.boxHoursClass).html(hours); obj.find('.' + _this.opts.boxHoursTextClass).html(this.formatText(hours, 'hour')); obj.find('.' + _this.opts.boxMinClass).html(minutes); return obj.find('.' + _this.opts.boxSecClass).html(seconds); }; KKCountdown.prototype.formatText = function(nr, text) { var daysText, lastDigit, _this; _this = this; daysText = _this.opts[text + 'sText']; if (_this.opts.rusNumbers) { if (nr >= 5 && nr < 20) { return daysText = _this.opts[text + 'sText']; } else { lastDigit = ("" + nr).replace(/^\d+(\d)$/, '$1') * 1; if (lastDigit === 1) { return daysText = _this.opts[text + 'Text']; } else { if (lastDigit >= 2 && lastDigit <= 4) { return daysText = _this.opts[text + 's2Text']; } else { return daysText = _this.opts[text + 'sText']; } } } } else { if (nr === 1) { return daysText = _this.opts[text + 'Text']; } else { return daysText = _this.opts[text + 'sText']; } } }; KKCountdown.prototype.fixTime = function(nr) { if (nr < 10) { return nr = '0' + nr; } else { return nr = nr; } }; return KKCountdown; })(); $.fn.extend({ kkcountdown: function(option) { return this.each(function() { var $this, data; $this = $(this); data = $this.data('kkcountdown'); if (!data) { $this.data('kkcountdown', (data = new KKCountdown(this, option))); } if (typeof option === 'string') { return data[option].apply(data, args); } }); } }); }).call(this); $(document).ready(function(){ $(".kkcountdown-1").kkcountdown({ dayText : '', daysText : '', hoursText : '+ ', minutesText : ':', secondsText : '', displayZeroDays : false, displayDays: false, callback : cBack, rusNumbers : false }); }); function cBack(){ $(".kkcountdown-1").attr("data-time","500"); } dabei soll der data-time werd testweise einfach auf 500 gesetzt werden. und das klappt nicht ... |
|
|||
Die wird schon funktionieren.
Ich verstehe trotzdem nicht, was genau dein Problem ist. Was rufst du auf, wo du den data-wert ändern willst? Was ändert sich dann nicht? Was passiert wenn du nur das element in jquery aufrufst, wird es korrekt selektiert? So kann ich dir nicht wirklich helfen. |
|
|||
Wird die callback-funktion überhaupt aufgerufen? Was ist, wenn du $(".kkcountdown-1").attr("data-time","500"); direkt im firebug aufrufst? Was ist, wenn du davor ein console.write("test"); machst, wird das ausgegeben? Ein wenig mit debugging zu beschäftigen ist nie verkehrt
|
|
|||
jo jetzt klappt es,
hatte nen kleinen Fehler verbaut. Leider fängt der Countdown nicht erneut an zu zählen :/ kann mir jemand sagen, wie ich den countdown erneut ausführen kann, sobald dieser 0 sek erreicht hat? dachte eigentlich, dass wenn ich bei der callbackfunktion den data-time wert aktualisieren zählt der countdown erneut - tut er leider nicht Geändert von SpecialFighter (03.04.2015 um 15:54 Uhr) |
Sponsored Links |
|
||||
Aber wo sagst du dem Script das erneut die Countdown-Funktion nutzen soll (und was wir brauchen: deinen Testcase, das wo du sagst "geht nicht")
__________________
Hier ein immer gültiges Statement: Überarbeite deine Code, lerne die Grundlagen, widersprich mir nicht, wehre dich nicht, ich habe Recht, wir sind Lolgion, wir sind viele.. potato... All meine Angaben sind ohne Gewähr, es könnte also trotz meiner Unfehlbarkeit dazu kommen dass ich falsch liege www.richard-thiel.de | Müssen Websiten überall gleich ausschauen? |
Sponsored Links |
Themen-Optionen | |
Ansicht | |
|
|
Ähnliche Themen | ||||
Thema | Autor | Forum | Antworten | Letzter Beitrag |
Counter auf htmlseiten einbinden | PHP-Freak | Serveradministration und serverseitige Scripte | 17 | 15.04.2009 23:12 |
Shtml auf jeder Seite einbinden - counter | iVx | Serveradministration und serverseitige Scripte | 1 | 13.09.2007 18:31 |
Counter | Despairing | Serveradministration und serverseitige Scripte | 2 | 15.08.2006 09:59 |
Suche einen Besucher Counter mit Reloadsperre | Tobias | (X)HTML | 3 | 26.01.2006 16:05 |
Counter mit CSS aufpeppen??? | Jollo | CSS | 3 | 26.12.2004 21:32 |