JP
Joined
Activity
Posted in Setup Windows 10 Discussion
How did you fix this problem... please help
Posted in jQuery.ajax url: rails
In my code I have this button
<button class="btn btn-success btn-lg" id="check_module">Pay</button>
In my code I have this button
Pay
Expand snippet
when clicked on iframe opens from this javascript code
<script type="text/javascript" src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script type="text/javascript" src="https://service.iamport.kr/js/iamport.payment-1.1.5.js"></script>
<%= javascript_tag do %>
$("#check_module").click(function () {
IMP.init(''); //iamport 대신 자신의 "가맹점 식별코드"를 사용하시면 됩니다
IMP.request_pay({
merchant_uid : "<%= @merchant_uid %>",
name : '결제테스트',
amount : <%= @price %>,
buyer_email : '<%= current_user.email %>',
buyer_name : '<%= current_user.name %>',
buyer_tel : ' no phone ',
buyer_addr : ' course name: no address',
buyer_postcode : ' no postcode ',
m_redirect_url: "https://url"
}, function(rsp) {
if ( rsp.success ) {// Successful payment: Successful payment approval or issuance of a virtual account
// HTTP request using jQuery
jQuhttps://stackoverflow.com/questions/ask#ery.ajax({
url: "<%= payment_complete_path(:item_id => @item) %>", // Merchant server
method: "POST",
headers: { "Content-Type": "application/json" },
data: {
imp_uid: rsp.imp_uid,
merchant_uid: rsp.merchant_uid
}
}).done(function (data) {
// Logic executed on successful response from the merchant server through the payment API
})
} else {
var msg = '결제에 실패하였습니다.';
msg += '에러내용 : ' + rsp.error_msg;
}
});
});
<% end %>
but after submitting the form the transaction goes through successfully but it stays on the page
how can I make it to go to this url or this action
url: "<%= payment_complete_path(:item_id => @item) %>", // Merchant server
in my controller ?
Any help will be greatly appreciated. Thank you!
$: 'jquery/src/jquery',
jquery: 'jquery/src/jquery',
jQuery: 'jquery/src/jquery',
'window.jQuery': 'jquery',
Popper: ['popper.js', 'default']
why does the one above work for one javascript but for other javascript to work I have to have this
$: 'jquery',
jQuery: 'jquery',
'window.jQuery': 'jquery',
Popper: ['popper.js', 'default']
This is in the environment.js
I am trying to insert a new comment on to the page without reloading using stimulus and javascript ~ I tried following along Chris in the nested comments video (NOTE: my comment is like his POST not comment) but I am having trouble~ I was wondering if anyone could help
It saves to the database but it isn't inserting. (It shows up if I reload the page )
Here are the codes
In the comments controller after being saved
if @comment.save
respond_to do |format|
format.html { redirect_to course_unit_reading_passage_path(@course, @lesson), notice: 'Comment was
successfully created.' }
format.js
end
Since the above code is in the create
I've created create.js.erb
here is the code
var replies_form = document.querySelector("#comments")
replies_form.insertAdjacentHTML('afterbegin', '<%=j render partial: "lessons/comments/comment", locals: { comment: @comment }, format: :html %>')
var form_reply = replies_form.querySelector("form")
form_reply.reset()
form.classList.add("d-none")
And in the show page
<div id="comments">
<%= render partial: 'lessons/comments/comment' %>
<p></p>
</div>
Here is the form for the comment
<%= form_with model: [@course, @lesson, @comment], html: { class: local_assigns[:class], data: { target: local_assigns[:target]} } do |f| %>
<div class ="form-group">
<%= f.text_area :content, class: "form-control" %>
</div>
<div class="form-group">
<%= f.submit :class => "btn btn-success" %>
</div>
<% end %>
NOTE: comments partial is in the comments folder nested inside courses
Any help would be greatly appreciated~
Thank you!
Is there a way to detect users leaving a page and alerting them in rails or would it be better to use jquery?
Thank you!
Posted in Liking Posts Discussion
It works on Rails 6 after adding this to
config > webpack > environment.js
const { environment } = require('@rails/webpacker')
const webpack = require('webpack')
environment.plugins.prepend('Provide',
new webpack.ProvidePlugin({
$: 'jquery/src/jquery',
jquery: 'jquery/src/jquery',
jQuery: 'jquery/src/jquery',
'window.jQuery': 'jquery'
})
)
module.exports = environment
Posted in Duration of a video in the listing page
Thank you!!
Posted in Duration of a video in the listing page
Chris ~ May I ask how you are handling/doing the duration of the video on the listing page? Are you saving it in the database? if you are saving it in the database, which data type are you using? are you entering it manually? are you using a gem? Thank you!
Is there a follow-up episode for this? If there is ~ do you know where I can find this?
here is the asset_root: that i found
I was having hard time and I found this
it seems to work ~
https://github.githubassets.com/images/icons/
wow !
Hello ~ I have been trying to figure out how to get the dropdown menu like the one in this forum to show the category after the page refreshes ~ I have been trying to do it using javascript and bootstrap ~ are there better ways to do it in rails? I have been stuck for hours :(
any guidance would be greatly appreciated.
Thank you!