asia_Kstyle3/modules/e_paper/_subscriber.html.erb

40 lines
1.2 KiB
Plaintext

<div class="epaper-form" id="form_{{subpart-id}}" style="margin-top:20px;">
<form action="" class="form-horizontal">
<div class="form-group">
<div class="col-sm-10 subscribe-email">
<input type="text" name="email" placeholder="Email">
</div>
</div>
<div class="form-group ">
<div class="col-sm-10 subscribe-buttons">
<input type="submit" data-type="subscribe" class="btn btn-primary" value="Subscribe">
<input type="submit" data-type="unsubscribe" class="btn btn-danger" value="Unsubscribe">
</div>
</div>
</form>
</div>
<script type="text/javascript">
$("#form_{{subpart-id}} form input[type=submit]").on("click",function(){
var el = $(this),
val = $("#form_{{subpart-id}} input[name=email]").val(),
url = null;
if(el.data("type") == "subscribe"){
url = "/xhr/epaper/subscribeuser";
}else if(el.data("type") == "unsubscribe"){
url = "/xhr/epaper/unsubscribeuser"
}
if(val != ""){
$.ajax({
url : url,
data : {"email" : val, "language" : I18n.locale},
dataType : "json",
type : "get"
}).done(function(data){
alert(data.msg);
$("#form_{{subpart-id}} form")[0].reset();
})
}
return false;
})
</script>