Comments (18)
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.
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.
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.
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.
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.
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.
from remotipart.
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.
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.
@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.
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.
@thiagobrandam I tried your fork, but that is not fixing that issue for me.
from remotipart.
@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.
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.
@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.
Any news on this? The specs pass and it works fine in the example app. I'm guessing it's not remotipart.
from remotipart.
Closing the issue, let me know if it needs to be reopened.
from remotipart.
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.
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)
- Rails 3.2 not working HOT 2
- Form with remote: true still send as HTML HOT 13
- Wrong HTML escaping for data type html HOT 3
- HTML response from js.erb HOT 1
- Rails 5 support HOT 6
- File Upload fields disappear on form validation failure HOT 2
- Rails 5.1.1 - Photo not displayed in the view when the latter is rendered in AJAX after a photo upload HOT 1
- remotipart response returned in browser POST response but is not inserted in to document when using cocoon gem? HOT 3
- ajax.complete is deprecated in jQuery 3+
- Is this Gem being maintained? HOT 2
- With web-console HOT 5
- Version 1.4.1 undefined local variable or method `controller' HOT 5
- Undefined local variable or method `controller` HOT 1
- Not getting the ajax:remotipartComplete event
- Add support for using via webpack HOT 1
- Not compatible with active_scaffold HOT 6
- Method whose arguments are used as raw SQL
- Depracation warning in Rails 6: Initialization autoloaded the constants ActionText::ContentHelper and ActionText::TagHelper. HOT 1
- Rails 6 / 6.1 deprecation warning for #content_type HOT 1
- DEPRECATION WARNING: render file: should be given the absolute path to a file
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from remotipart.