Rovak / InlineAttachment

Easily paste and upload files/images in plain textareas
http://git.razko.nl/InlineAttachment
MIT License
619 stars 77 forks source link

Hmftwpr1 #27

Closed hmftw closed 10 years ago

hmftw commented 10 years ago

Hello Rovak!

I had found another solution:

    function attachInlineUpload() {

            $(".overContent:not(.clone) .OCone .imgContainer").inlineattach({              
                uploadUrl: 
                'index.php?action=DELETED&method=saveInlineImgUpload&format='+currentInlineUploadMethod+'&modus='+$('input[name="modi"]').val()+'&dated='+$('input[name="datum"]').val()+'&s='+$sess,
                uploadFieldName: 'imgUpload',
                neededAttrData: ['rel'],
                exFormData:  ['relatedToId']
            });

    }

There are no problems with the instance and so one. The Script is totally well written and I didn't seen the method onReceivedFile. The Project was written on base of textareas, I have modified it that image-Tags or Div-Tags.

I will had binded the InlineAttachment-Plugin to the object when the Clone of the container('overContent') are created, but now, I easily rewrite all objects after the user-interaction and because of the "set.each" @ Line 82+ the imgContainer will be right attached...

Important: I dont have modified the Vanilla JS variant of the editor.

PS: I hope my english is clearly understandable....

Rovak commented 10 years ago

Hi Hmftwpr1,

I like the idea of being able to add extra parameters when sending the file. The other additions are from what i read in the comments specific for your use case, i'm not sure if they are helpful to be included in the library.

You could implement your own editor so you can drop files on a image. Besides that i think, if i correctly understand the given example, that the solution can be simplified for your use case. You could pass the attributes that you want to send using the extraParams option.

function attachInlineUpload() {
  var $el = $(".overContent:not(.clone) .OCone .imgContainer");
  $el.inlineattach({
    uploadUrl: '...',
    uploadFieldName: 'imgUpload',
    // Add the attribute data here, they will then be included in the post data
    extraParams: {
      relatedToId: $el.attr('rel')
    }
  });
}

This way you can set the extraParams during the init, and there is no unneeded complexity.

hmftw commented 10 years ago

Hello Rovak,

thank you for the Code Review. I had changed the default Values because it causes Errors. I am using Div-Tags instead of Textareas.

Thank you for your advice, but your example with the attachInlineUpload Function will give the Rel-Attributecontent of the last Item of the current Set.

I have solved that problem with an each over all imgContainers. I have applied all changes and advices in my project, thank you.

Rovak commented 10 years ago

Good to hear that you got it worked out, closing this PR.