php – 使用可保存和可检索的内容创建一个粘性页面的最佳方法是什么?
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了php – 使用可保存和可检索的内容创建一个粘性页面的最佳方法是什么?,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含3367字,纯文字阅读大概需要5分钟。
内容图文
![php – 使用可保存和可检索的内容创建一个粘性页面的最佳方法是什么?](/upload/InfoBanner/zyjiaocheng/798/74da384aed6f4a0bbda3d54ac3dc4f2f.jpg)
我看过sticky notes with php and jquery和jStickyNote,虽然两者看起来都很漂亮,但他们缺少一些我追求的元素.我还没有找到一种方法允许特定用户修改他们创建的胶粘物,也没有找到一种方法将他们的胶粘物保存到我的数据库中.我是,并且想继续使用php,mysql和jquery.我已经想到了第一个链接,我可以将创建的图像保存到文件夹中并将URL保存到该数据库中但是我不能返回并允许用户更改粘贴的内容.使用第二个链接似乎根本不支持保存粘性.我还想创建一个功能,在消息板上添加胶粘物(供所有人看),以随机放置的方式看起来很自然.对这两个问题的任何想法?
解决方法:
这里有一些javascript应该有所帮助:
// Called when the edit (A) button is pressed
function edit(event, editButton)
{
// Get existing title and change element to textarea
var stickyTitle = $(editButton).parent().find('p.stickyTitle');
var textareaTitle = $(document.createElement('textarea')).addClass('textareaTitle');
$(textareaTitle).text(stickyTitle.html());
// Get existing description and change element to textarea
var stickyDescription = $(editButton).parent().find('p.stickyDescription');
var textareaDescription = $(document.createElement('textarea')).addClass('textareaDescription');
$(textareaDescription).text(stickyDescription.html());
// Create save button
var saveButton = $(document.createElement('div')).addClass('jSticky-create');
// Add save button, then replace title, then replace description, then remove edit button
$(editButton).before(saveButton);
$(editButton).parent().find('p.stickyTitle').before(textareaTitle).remove();
$(editButton).parent().find('p.stickyDescription').before(textareaDescription).remove();
$(editButton).remove();
// Set description textarea focus and set button actions
textareaTitle.focus();
setActions();
}
// Called when the save (tick) button is pressed
function save(event, saveButton)
{
// Get existing title and change element to paragraph
var textareaTitle = $(saveButton).parent().find('textarea.textareaTitle');
var stickyTitle = $(document.createElement('p')).addClass('stickyTitle');
var newTitleValue = textareaTitle.val();
$(stickyTitle).html(newTitleValue);
// Get existing description and change element to paragraph
var textareaDescription = $(saveButton).parent().find('textarea.textareaDescription');
var stickyDescription = $(document.createElement('p')).addClass('stickyDescription');
var newDescriptionValue = textareaDescription.val();
$(stickyDescription).html(newDescriptionValue);
// Create edit button
var editButton = $(document.createElement('div')).addClass('jSticky-edit');
// Add edit button, then replace title, then replace description, then remove save button
$(saveButton).before(editButton);
$(saveButton).parent().find('textarea.textareaTitle').before(stickyTitle).remove();
$(saveButton).parent().find('textarea.textareaDescription').before(stickyDescription).remove();
$(saveButton).remove();
// Set button actions
setActions();
// Add the object to the ads div
$('#ads').append(object);
// Update your database here
// by calling the saveAd.php
}
function setActions()
{
// call these after changes are made to anything
$('.jSticky-create').unbind('click').click(function(e)
{
save(e, this);
});
$('.jSticky-edit').unbind('click').click(function(e)
{
edit(e, this);
});
$('.jSticky-delete').unbind('click').click(function(e)
{
remove(e, this);
});
}
function remove(event, deleteButton)
{
var stickyMaster = $(deleteButton).parent();
$(stickyMaster).remove();
//then call savead.php with delete parameter
}
内容总结
以上是互联网集市为您收集整理的php – 使用可保存和可检索的内容创建一个粘性页面的最佳方法是什么?全部内容,希望文章能够帮你解决php – 使用可保存和可检索的内容创建一个粘性页面的最佳方法是什么?所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。