开发者

Easiest way to create twitter-like status update widget

开发者 https://www.devze.com 2022-12-25 01:56 出处:网络
I want a widget that allows users to add a request if that request hasnt already been added, or vote for a request if it has already been added.when 开发者_C百科a user adds a request, i want it to imm

I want a widget that allows users to add a request if that request hasnt already been added, or vote for a request if it has already been added. when 开发者_C百科a user adds a request, i want it to immediately appear as the first element of the list, like what would happen to your timeline if you made new tweet. ive tried to look for a jquery plugin that offers this functionality, but i was unsuccessful (maybe i couldnt think of the right terms to search for??).

i dont have enough faith in my js skills to write this from scratch, so id rather find a template to start with. Thanks.


I don't think that would be very hard to create from scratch.

In a conceptual model:

Create the form to add the request

Store it somewhere (XML, Database, ... whatever you feel it suits your needs)

Retrieve it from the database/XMl file, sorting it by post date or lastvote date (whichever is new)

Edit:

Ah! So the part you're looking for is right after the request is posted, you want it to appear in the top of the list, without refreshing the page. Is that it?

With JScript, just raise an Event when the user clicks the post button that handles posting.

That event would trigger a function that would re-run the database query, for instance (through Ajax or something). Or... it could just insert some HTML in the top of the list. If its a table, something like:

document.write("<tr><td>" + Request_Title + "</td></tr>
                <tr><td>" + Request_Text + "</td></tr>
                <tr><td>" + Request_Author + "</td></tr>")

that should do the trick

0

精彩评论

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