Note that there are some explanatory texts on larger screens.

plurals
  1. POfirst time implementing module pattern variable is undefined
    text
    copied!<p>here is my code </p> <pre><code> var s; var AddEvent = { settings : { saveButton : $('#uploadfiles1'), cancelSpeech : $('.cancelSpeech'), datePicker : $(".datepicker"), eventName : $('input[name=eventname]'), eventDate : $('input[name=eventdate]') }, init:function(s){ s = this.settings; this.BindEvents(); $('.Wallpapers').addClass('active'); $('input, textarea').placeholder(); }, BindEvents:function(){ this.CancelButton(); this.DatePicker(); // this.SaveButton(); $('input[type=text],textarea').on('keyup change',function(){ AddEvent.FieldsCheck(); }); }, CancelButton: function() { s.cancelSpeech.on('click',function(){ var referrer = document.referrer; window.location = referrer; }); }, DatePicker :function() { s.datePicker.datepicker({ //defaultDate: +7, showOtherMonths: true, autoSize: true, //appendText: '(dd-mm-yyyy)', dateFormat: 'dd/mm/yy' }); }, SaveButton: function() { this.ClearFields(); }, FieldsCheck: function() { alert(s.eventName.attr('name')); if(s.eventName.val()!='' &amp;&amp; s.eventDate.val() !='' &amp;&amp; $('textarea').val()!='') { s.saveButton.removeAttr('disabled').removeClass('disabled'); } else s.saveButton.attr('disabled','disabled').addClass('disabled'); }, ClearFields:function() { $('input,textarea').val(''); this.FieldsCheck(); } }; $(function(){ AddEvent.init(s); }); </code></pre> <p>i am impletenting this example <a href="http://css-tricks.com/how-do-you-structure-javascript-the-module-pattern-edition/" rel="nofollow">http://css-tricks.com/how-do-you-structure-javascript-the-module-pattern-edition/</a></p> <p>but each time when i type in my input field at this line i get undefined in alert</p> <pre><code>alert(s.eventName.attr('name')); </code></pre> <p>please tell me what am i doing wrong i tried to search but couldnt find anything usefull.</p> <p>edit: here i created a little <a href="http://jsfiddle.net/Lp6rE/9/" rel="nofollow">jsfiddle</a> i am getting</p> <pre><code>TypeError: this.settings is undefined [Break On This Error] console.log(this.settings.eventName.attr('id')); </code></pre> <p>thanks</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload