Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jQuery fn #6

Open
sambenne opened this issue Jun 7, 2011 · 5 comments
Open

jQuery fn #6

sambenne opened this issue Jun 7, 2011 · 5 comments

Comments

@sambenne
Copy link

sambenne commented Jun 7, 2011

You are doing $.fn.toastmessage which means that you have to do $().toastmessage. But if you remove .fn then you can remove the (). Since you are not attaching it to anything.

I think I remember seeing a way of doing both. Will have to find that out again.

@paulmillr
Copy link

Also, it is a bad practice to create bunch of anonymous functions on each 'toast message'. The good way is to use javascript prototypes. It could reduce memory usage by 5-15 times.
I've forked jquery toastmessage six months ago and improved it much (also added desktop notification support), see:
https://github.com/pbagwl/tire/blob/5daa5946420f20c5921e220d78162af4d777d7ec/js/tire.js#L218
Fork's syntax is: $.notification('message') / $.notification('message', 'warning') etc.

@drewwells
Copy link

Thanks for improving this, I was about to open an issue for the $() too.

@paulmillr your link is broken

@akquinet If you want people to pass in something ie. special dom element to use for a Toast message you would use something like this:

$.toastmessage({ dom: 'domElement' });
$.fn.toastmessage = function(){
  $.toastmessage({ dom: this })
}

@drewwells
Copy link

Thanks, did you write it in Coffeescript for kicks n' giggles or was it useful to do so?

@paulmillr
Copy link

As it was already rewritten by me in javascript, CoffeeScript version was made just for fun, yup.
I got tired from JS as a development language two months ago so I decided to learn CS and now I'm using it at work (with backbone.js). Great language, it eliminates many disadvantages of javascript or adds features, that would be available only in future (ecmascript harmony).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants