开发者

Jquery/Javascript gmail style stuff for message inbox, such as select all message using checkbox etc

开发者 https://www.devze.com 2023-02-05 01:37 出处:网络
I am enjoying the fact that I\'m here building a private message inbox for my website after building a full user signup/login and activation system when a few months ago I thought I wouldn\'t have eno

I am enjoying the fact that I'm here building a private message inbox for my website after building a full user signup/login and activation system when a few months ago I thought I wouldn't have enough patience to learn this stuff.

Anyway to my question. I am currently building the private message inbox for my users and wondering if there are any jquery/javascript stuff I can use to make my inbox more like the gmail inbox.

E.G. Gmail allows you to select all read messages or unread or starred or unstarred or none of the messages using a checkbox. I would like to add this kind of feature to my website 开发者_运维问答and I'm sure the easiest way to achieve this would be using a jquery/javascript script.

I would appreciate if someone could provide some links or info to where I can find several of these types of scripts to use with my inbox page. Thanks

EDIT: Would also like to note that I would like the checkbox to be in a dropdown just like gmails.


I suggest breaking each requirement you have into pieces (that's general problem solving advice).
So let's take your example. you want to allow a user to select all checkboxes, we want jQuery to select all checkboxes, and select them:

$(':checkbox').attr('checked','checked');

Of course, you have to choose where/when you want that to execute, but again, that's a separate part of the problem.

When we uncheck them, we might do something like:

$(':checkbox').removeAttr('checked');

If you want read/unread, you'll want to work on all the selected items, so you'll want something like (of course, in a deployed app, you'd want to make sure that this doesn't grab radio buttons or other checkboxes etc.):

$('#read').click(function(){
  $(':checked').each(function(){
    // change their background colour, maybe
  })
});


hi you can do something like this

$("#select-all").click(function(){
      $("input:checkbox").attr('checked', $(this).attr('checked'));
});

(Haven't tested it though)

Edit: oops! i wrote select by mistake :P and you can differentiate between read, unread etc by using classes on the them

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号