• Daft Punk
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 1
    Replies
Can I pass a variable into an apex:actionFunction call as follows:

    deleteThing(thing_id);

    <apex:actionFunction name="deleteThing" action="{!deleteAttachment}" reRender="none" oncomplete="remove_deleted_thing(thing_id)">
        <apex:param name="thingToDelete" value="" assignTo="{!selectedAttachmentId}" /> 
    </apex:actionFunction>

    public String selectedAttachmentId {get; set;}

    public PageReference deleteAttachment() {
        Attachment attachment = getSelectedAttachment();
        delete attachment;
        return null;
    }

    private Attachment getSelectedAttachment() {
        return [SELECT Id FROM Attachment WHERE Id= :selectedAttachmentId];
    }

    function remove_deleted_thing(thing_id) {
        console.log(thing_id);
    }
So that after {!deleteAttachment} runs in my controller, thing_id will be passed to remove_deleted_thing()?

I'm not even getting 'undefined' in my console now, so I assume I'm doing somthing wrong here. The code does what it's supposed to do up until remove_deleted_thing.

Amy suggestions or advice would be greatly appreciated.
The majority of my VF page is built dynamically with jQuery. I'm looking to upload some attachments, I can accomplish this with inputFile, but I can't use any apex elements because everything else on the page is made with jQuery, body, tables etc...

So can I replace

    <apex:inputFile value="{!attachment.body}" filename="{!attachment.name}" id="file" title="Upload Attachment" styleclass="fileType"/> 

with this
   
<input type="file" value="{!attachment.body}" name="{!attachment.name}" id="file" accept="image/jpeg, image/png"> </input>


     
The majority of my VF page is built dynamically with jQuery. I'm looking to upload some attachments, I can accomplish this with inputFile, but I can't use any apex elements because everything else on the page is made with jQuery, body, tables etc...

So can I replace

    <apex:inputFile value="{!attachment.body}" filename="{!attachment.name}" id="file" title="Upload Attachment" styleclass="fileType"/> 

with this
   
<input type="file" value="{!attachment.body}" name="{!attachment.name}" id="file" accept="image/jpeg, image/png"> </input>