[Slightly difficult question] how to modify theme without page refresh Hitskin_logo Hitskin.com

This is a Hitskin.com skin preview
Install the skinReturn to the skin page

The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.
3 posters

    [Slightly difficult question] how to modify theme without page refresh

    developer.ryan
    developer.ryan
    Forumember


    Posts : 98
    Reputation : 6
    Language : English,Chinese,Italian,French
    Location : The doors of development

    Solved [Slightly difficult question] how to modify theme without page refresh

    Post by developer.ryan September 1st 2015, 2:07 pm

    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


    Last edited by developer.ryan on September 2nd 2015, 7:49 pm; edited 1 time in total
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    Solved Re: [Slightly difficult question] how to modify theme without page refresh

    Post by Ange Tuteur September 1st 2015, 2:32 pm

    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 :
    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.
    developer.ryan
    developer.ryan
    Forumember


    Posts : 98
    Reputation : 6
    Language : English,Chinese,Italian,French
    Location : The doors of development

    Solved Re: [Slightly difficult question] how to modify theme without page refresh

    Post by developer.ryan September 1st 2015, 8:01 pm

    Thank you, but nothing happens

    In my profile I can modify date of birth

    Example

    [Slightly difficult question] how to modify theme without page refresh Newq10

    i want same this
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    Solved Re: [Slightly difficult question] how to modify theme without page refresh

    Post by Ange Tuteur September 1st 2015, 8:17 pm

    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.
    developer.ryan
    developer.ryan
    Forumember


    Posts : 98
    Reputation : 6
    Language : English,Chinese,Italian,French
    Location : The doors of development

    Solved Re: [Slightly difficult question] how to modify theme without page refresh

    Post by developer.ryan September 1st 2015, 11:56 pm

    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    Solved Re: [Slightly difficult question] how to modify theme without page refresh

    Post by Ange Tuteur September 2nd 2015, 12:27 pm

    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
    Code:
    $(function() {
      var h2 = $('h2.topic-title')[0],
          a = document.createElement('A');

      // edit button attributes
      a.innerHTML = '&nbsp;<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
    developer.ryan
    developer.ryan
    Forumember


    Posts : 98
    Reputation : 6
    Language : English,Chinese,Italian,French
    Location : The doors of development

    Solved Re: [Slightly difficult question] how to modify theme without page refresh

    Post by developer.ryan September 2nd 2015, 7:48 pm

    Wow this is awesome king  

    it works for me without any problem

    Thank you very much. :rose:
    SLGray
    SLGray
    Administrator
    Administrator


    Male Posts : 51552
    Reputation : 3523
    Language : English
    Location : United States

    Solved Re: [Slightly difficult question] how to modify theme without page refresh

    Post by SLGray September 2nd 2015, 8:47 pm

    Topic solved and archived



    [Slightly difficult question] how to modify theme without page refresh Slgray10

    When your topic has been solved, ensure you mark the topic solved.
    Never post your email in public.