[Slightly difficult question] how to modify theme without page refresh
3 posters
Page 1 of 1
[Slightly difficult question] how to modify theme without page refresh
Hi everyone
I have a question a little difficult
How to modify the title of the topic without refresh page
any that i edit the title in the same subject without departing from the same page
I have a question a little difficult
How to modify the title of the topic without refresh page
any that i edit the title in the same subject without departing from the same page
Last edited by developer.ryan on September 2nd 2015, 7:49 pm; edited 1 time in total
Re: [Slightly difficult question] how to modify theme without page refresh
To do anything like that, you'd need to utilize AJAX. This is an example of how you could update the content of a post :
You'd need to replace post_id with a valid post identifier. ( e.g. 1, 2, 3.. ) Furthermore, for this example to work you'd need to disable the security option "disallow unofficial forms to post on the forum" via General > Security.
If you want to get past that you need to first send a GET request to return the form data. For example :
You can then proceed to manipulate the data as needed and then submit a POST request to update the data.
- Code:
$.post('/post', {
subject : 'Topic title',
message : 'Message content',
mode : 'editpost',
p : 'post_id',
post : 1
});
You'd need to replace post_id with a valid post identifier. ( e.g. 1, 2, 3.. ) Furthermore, for this example to work you'd need to disable the security option "disallow unofficial forms to post on the forum" via General > Security.
If you want to get past that you need to first send a GET request to return the form data. For example :
- Code:
$.get('/post?mode=editpost&p=1', function(data) {
var form = $('form[name="post"]', data).serialize(); // get the serialized form data
console.log(form); // view data in the console
});
You can then proceed to manipulate the data as needed and then submit a POST request to update the data.
Re: [Slightly difficult question] how to modify theme without page refresh
Thank you, but nothing happens
In my profile I can modify date of birth
Example
i want same this
In my profile I can modify date of birth
Example
i want same this
Re: [Slightly difficult question] how to modify theme without page refresh
I'll need more information before I can do anything. Such as the URL of your forum, that way I have an understanding of the document.
Re: [Slightly difficult question] how to modify theme without page refresh
Thanks, version phpbb3 will be easy to work with.
Go to Modules > JavaScript codes management and Create a new script with the following settings.
Placement : In the topics
That will add a edit button next to the topic title of the first post. So it works correctly on all pages of a topic I'd recommend enabling the following option.
General > Messages > Config > Always show the first post in the topics : Yes
Go to Modules > JavaScript codes management and Create a new script with the following settings.
Placement : In the topics
- Code:
$(function() {
var h2 = $('h2.topic-title')[0],
a = document.createElement('A');
// edit button attributes
a.innerHTML = ' <img src="http://i21.servimg.com/u/f21/18/21/60/73/10053510.png" alt="Edit Title"/>';
a.title = 'Edit topic title';
a.className = 'editTitle';
a.href = '#';
// edit function
a.onclick = function(e) {
var t = this;
e.preventDefault();
$.get('/post?mode=editpost&p=' + t.previousSibling.href.replace(/.*?#(\d+)/, '$1'), function(d) {
var form = $('form[name="post"]', d)[0],
newTitle = prompt('Please insert a new title for this topic.', form.subject.value);
if (newTitle) {
form.subject.value = newTitle;
$.post('/post', $(form).serialize() + '&post=1', function(data) {
$('h2.topic-title a[href^="/t"]').text(newTitle);
});
}
});
};
if (h2 && /mode=editpost/.test(h2.previousSibling.innerHTML)) h2.appendChild(a);
'par ange tuteur';
});
That will add a edit button next to the topic title of the first post. So it works correctly on all pages of a topic I'd recommend enabling the following option.
General > Messages > Config > Always show the first post in the topics : Yes
Re: [Slightly difficult question] how to modify theme without page refresh
Wow this is awesome
it works for me without any problem
Thank you very much.
it works for me without any problem
Thank you very much.
Re: [Slightly difficult question] how to modify theme without page refresh
Topic solved and archived
Lost Founder's Password |Forum's Utilities |Report a Forum |General Rules |FAQ |Tricks & Tips
You need one post to send a PM.
You need one post to send a PM.
When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.
Similar topics
» Modify theme.
» Question on how-to-modify the group legend
» Refresh iframe and not the page
» A Refresh Page Button
» Random Div Shown on page refresh
» Question on how-to-modify the group legend
» Refresh iframe and not the page
» A Refresh Page Button
» Random Div Shown on page refresh
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum