Skip to:
Content
Pages
Categories
Search
Top
Bottom

[Resolved] Help me creating simple and useful plugin !

  • Avatar of mahdiar
    mahdiar
    Participant

    @mahdiar

    Hi
    I’d like to add a button in the activity post form . When someone click on it it add some cod to the activity post text area !
    I know how to do it with javascript but it doesnt worked ! How can I do that ?

Viewing 13 replies - 1 through 13 (of 13 total)
  • Avatar of @modemlooper
    @modemlooper
    Moderator

    @modemlooper

    Code gets stripped from post form on submit so you’d have to filter the form as well. The code for activity submit is in global.js file in the folder _inc

    You can try to add your JavaScript there but like i said code gets stripped on submit.

    Avatar of mahdiar
    mahdiar
    Participant

    @mahdiar

    Thanks ! Sorry ! In fact I don’t get what you mean . I write a code and it works offline . Could you pleas check it ?
    `

    function addtext(val) {
    document.whatsnewform.whatsnew.value += val;
    }

    <img src="s33.gif" onclick=addtext(':)‘) alt=”Smiley face” />
    Avatar of @modemlooper
    @modemlooper
    Moderator

    @modemlooper

    As for the JavaScript not working; the activity posting mechanism heavily uses jquery to function and is most likely killing your code. That is why is suggest you look through global.js to understand how it’s implemented.

    Avatar of mahdiar
    mahdiar
    Participant

    @mahdiar

    Thanks ! I get it . But I should learn jquery :) I try a new code

    Avatar of @modemlooper
    @modemlooper
    Moderator

    @modemlooper

    Try this site for a basic jquery lesson http://jqfundamentals.com/

    Avatar of mahdiar
    mahdiar
    Participant

    @mahdiar

    I learn it some how . I write the following code but I have a problem . When I click on the image the text is added but when I type something in the text area it doesn’t work any more !!!
    What’s the problem ?
    `

    $(document).ready(function(){
    $(“#sml”).click(function(){
    $(“#whatsnew”).append(“e”);

    });
    });


    <img id="sml" src="s33.gif" onclick=addtext(':)‘) alt=”Smiley face” />

    `

    Avatar of @modemlooper
    @modemlooper
    Moderator

    @modemlooper

    Your code doesn’t display correctly here can you place it between backticks `

    Avatar of mahdiar
    mahdiar
    Participant

    @mahdiar

    I corrected it .

    Avatar of @modemlooper
    @modemlooper
    Moderator

    @modemlooper

    `

    $(document).ready(function(){
    $(“#sml”).click(function(){
    $(“#whatsnew”).val(“:)“);

    });
    });


    Smiley face

    `

    Avatar of mahdiar
    mahdiar
    Participant

    @mahdiar

    Thanks for your reply . I’d like to add text Not to change it !
    For example :
    I write ” Hello world ” Then click on the image and “:)” added to the text . (Hello world :) )
    The code you write change the value to the “:)

    Avatar of @modemlooper
    @modemlooper
    Moderator

    @modemlooper

    `$(document).ready(function(){
    $(“#sml”).click(function(){
    var text = $(“textarea#whatsnew”).val();
    var newtext = text + ‘ : )';
    $(“textarea#whatsnew”).val(newtext);
    });
    });`

    Avatar of mahdiar
    mahdiar
    Participant

    @mahdiar

    Thanks A lot !
    Sorry for my late answer ! I didn’t have any time to test it .
    I tested it and it worked .
    Now I should make the plugin . Is there any document that I can use ?

    Avatar of @modemlooper
    @modemlooper
    Moderator

    @modemlooper

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

You must be logged in to reply to this topic.