Coder Social home page Coder Social logo

Comments (18)

bjensen avatar bjensen commented on August 31, 2024

I think I have the same issue...I have a remoti_response block in my create.js.erb file. I can see using firebug that the contents I get returned is valid js, but is is not being evaluated by the browser as if the dataType isnt set to script..

Im using remotipart master. Rails 3.0.9 and jquery-rails 1.0.19

from remotipart.

bjensen avatar bjensen commented on August 31, 2024

Here is what my form submit looks like:

Started POST "/account?id=1418" for 127.0.0.1 at 2011-12-10 12:02:57 +0100
Processing by StudentsController#update as JS
Parameters: {"user"=>{"photo"=>#<ActionDispatch::Http::UploadedFile:0x007f8479e223e0 @original_filename="claus forstander.jpg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name="user[photo]"; filename="john.jpg"\r\nContent-Type: image/jpeg\r\n", @tempfile=#File:/var/folders/k6/sf3hfpg93xdcfktpk4m8v2lh0000gn/T/RackMultipart20111210-25826-c6dkeo>}, "utf8"=>"✓", "authenticity_token"=>"wKNI8hhauzwSoYVr7V4T5gABZXIXlid5W0WRWQV+zaE=", "stay_id"=>"23", "user_id"=>"1418", "remotipart_submitted"=>"true", "X-Requested-With"=>"IFrame", "X-Http-Accept"=>"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript, /; q=0.01", "id"=>"1418"}
...
...
...
Rendered students/update.js.erb (56.9ms)

from remotipart.

laleshii avatar laleshii commented on August 31, 2024

I see nobody watches the issues on this project.
I finally found out what the problem is. It seems nested escape_javascript does not work when the result is executed using the iframe method.

I have the following code in the create/update js:

$('#contenttext').html('<%= escape_javascript(render "form", :content => @content,:content_text => @selected_ctext ) %>');

and in the _form partial I have this link added:

def link_to_add_fields(name, f, association)
   new_object = f.object.class.reflect_on_association(association).klass.new
   fields = f.fields_for(association, new_object, :child_index => "new_#{association}") do |builder|
      render(association.to_s.singularize + "_fields", :f => builder)
   end
   link_to_function(name, "add_fields(this, '#{association}', '#{escape_javascript(fields)}')") 
end

This works when I do not upload any file but fails when I do.

from remotipart.

bjensen avatar bjensen commented on August 31, 2024

laleshii What if you just put this into your create.js.erb:

<%= remotipart_response do%>
alert("hello world");
<% end %>

Does that then work?

from remotipart.

laleshii avatar laleshii commented on August 31, 2024

Yes that works properly.

I downloaded the test application and tried to see what were the differences. From what I've seen it was only that I used "" wrappers and not ''. After I replaced everything I could it worked partially. It works now besides the above auto generated link which auto generates the code with "" wrappers.

from remotipart.

laleshii avatar laleshii commented on August 31, 2024

This is not a issue it's a bug in the way the result is rendered.

You can try for yourself. Put this in a form response which uses remotiform for AJAX file upload and you will see the result only gets properly rendered you don't upload anything and the classic js response is used.

http://pastebin.com/Ah5MdFav

from remotipart.

bjensen avatar bjensen commented on August 31, 2024

Im working on demo project that will demonstrate the bug. Ill put it on github and share the url

@laleshii if you attach a file does it then send a HTML request and a JS request if you dont? That is my problem.

update: If I use my simple demo project then it works fine, however if I use it in a client project with over 30 gems then it is messing up, as if some other gem is conflicting. I hope @JangoSteve will look into this issue as well..

My demo project is here: github.com/bjensen/remotipart_bug and it works fine. I need to experiment by adding more gems to the project to see which gem is causing the conflict.

from remotipart.

bjensen avatar bjensen commented on August 31, 2024

I finally figured it out my issue!

It was a conflict with wicked_pdf, once I removed that from my Gemfile things were running smoothly. I am not sure yet why this is the case but Ill keep digging.

@laleshii are you using wicked_pdf in your project? What happens if you use my demo project? If your not using wicked_pdf and your still getting errors then maybe you should do as me and remove gems while testing if the functionality of remotipart works.

from remotipart.

terrell avatar terrell commented on August 31, 2024

@bjensen In my application, I can confirm the same issue you found and also that removing wicked_pdf resolves the issue.

Too bad that I need wicked_pdf though, so I'm still working on finding a solution.

from remotipart.

0xradical avatar 0xradical commented on August 31, 2024

Hi @bjensen , the issue is both wicked_pdf and remotipart override the render method in some way: wicked_pdf through alias_method_chain and remotipart overrides render through "module inheritance", thus one of the render doesnt get called:

class A1
 def meth
  puts 'a1'
 end
end

class A2
  def meth
    puts 'a2'
  end
end

module B
  def self.included(base)
    base.class_eval do
      alias_method_chain :meth, :feature
    end
  end
  def meth_with_feature
    puts 'b'
    meth_without_feature
  end
end

module C
  def meth
    puts 'c'
    super
  end
end

A1.send :include, B
A1.send :include, C

A2.send :include, C
A2.send :include, B

puts A1.new.meth
# b
# a1
puts A2.new.meth
# b
# a2

they dont talk to each other ...

from remotipart.

bitboxer avatar bitboxer commented on August 31, 2024

@thiagobrandam I tried your fork, but that is not fixing that issue for me.

from remotipart.

0xradical avatar 0xradical commented on August 31, 2024

@bitboxer if you disable wicked_pdf and use the official remotipart gem, it does work, right? My fork works for me, so I don't know what could be happening, maybe there's some edge case I overlooked when I forked...

from remotipart.

bitboxer avatar bitboxer commented on August 31, 2024

No, I am not using wicked_pdf in my project. But I see the same problem @laleshii is reporting. I see the textarea, but the code is not executed. I think there are more problems with this than the problem with wicked :( .

from remotipart.

0xradical avatar 0xradical commented on August 31, 2024

@bitboxer I see ... My guess is that there is another gem causing you trouble, I suggest you disable all your gems one by one and test remotipart each time until it works.

from remotipart.

JangoSteve avatar JangoSteve commented on August 31, 2024

Any news on this? The specs pass and it works fine in the example app. I'm guessing it's not remotipart.

from remotipart.

JangoSteve avatar JangoSteve commented on August 31, 2024

Closing the issue, let me know if it needs to be reopened.

from remotipart.

terrell avatar terrell commented on August 31, 2024

To anyone else still experiencing this issue with wicked_pdf, you may try switching to wisepdf.

I recently switched to wisepdf and everything appears to work as it should now.

from remotipart.

notmatthancock avatar notmatthancock commented on August 31, 2024

Thank you!! I had this issue and removing wickedpdf resolved my issues as well.

Has anyone got wickedpdf and remotipart working friendly and could elucidate on what needs to be done to do so?

In the mean-time I will look into wisepdf.

from remotipart.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.