How can I change post settings via JS?

#22164
  • Resolved Philipp
    Rank Math free

    We need to have a way to update fields in the RankMath metabox via javascript – e.g., set the Snippet title/description on the press of a button.

    It’s easy to set the input field value of those fields. Our problem is that the snippet preview is not updated until we save the post.

    Can you point me to a JS documentation or tell us which function can be used to refresh the Snippet in the metabox?

    Here’s the JS code we have right now:

    jQuery("[name=rank_math_title]").val('New value');

    Thanks! Philipp 🙂

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hello,

    Thank you for contacting Rank Math today.

    Kindly allow me to consult our dev team about this and I will get back to you in a short while.

    Looking forward to helping you. Thank you.

    ​​​​​​

    Hello,

    Please use RankMathApp.metabox.updatePreview(); to update the preview:
    `
    jQuery(“[name=rank_math_title]”).val(‘New value’);
    RankMathApp.metabox.updatePreview();
    `

    This should update the preview.

    I hope that helps. Thank you.

    Awesome, that works perfectly!

    And thanks for the fast response 👍

    Hello,

    We are super happy that this resolved your issue. If you have any other questions in the future, know that we are here to help you.

    If you don’t mind me asking, could you please leave us a review (if you haven’t already) on https://wordpress.org/support/plugin/seo-by-rank-math/reviews/?rate=5#new-post about your overall experience with Rank Math? We appreciate your time and patience.

    If you do have another question in the future, please feel free to create a new forum topic, and it will be our pleasure to assist you again.

    Thank you.

Viewing 4 replies - 1 through 4 (of 4 total)

The ticket ‘How can I change post settings via JS?’ is closed to new replies.